diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-11-19 14:28:55 +0100 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2016-12-02 07:50:11 +0000 |
commit | e5ad693f91632219407b15137b8863223919849b (patch) | |
tree | a54ee0e142190707e0b52042d36b66de5a2f403c /src/qt/utilitydialog.cpp | |
parent | e4bea4fb84dceab44f8a8de4f8b974ba8bb98529 (diff) | |
download | bitcoin-e5ad693f91632219407b15137b8863223919849b.tar.xz |
qt: Avoid shutdownwindow-related memory leak
Store a reference to the shutdown window on BitcoinApplication,
so that it will be deleted when exiting the main loop.
Github-Pull: #9190
Rebased-From: 5204598f8d07d7432d91e9b8781806d2f3d16415
Diffstat (limited to 'src/qt/utilitydialog.cpp')
-rw-r--r-- | src/qt/utilitydialog.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 947bcdb15a..4ec022881c 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -171,22 +171,20 @@ ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f): setLayout(layout); } -void ShutdownWindow::showShutdownWindow(BitcoinGUI *window) +QWidget *ShutdownWindow::showShutdownWindow(BitcoinGUI *window) { if (!window) - return; + return nullptr; // Show a simple window indicating shutdown status QWidget *shutdownWindow = new ShutdownWindow(); - // We don't hold a direct pointer to the shutdown window after creation, so use - // Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually. - shutdownWindow->setAttribute(Qt::WA_DeleteOnClose); shutdownWindow->setWindowTitle(window->windowTitle()); // Center shutdown window at where main window was const QPoint global = window->mapToGlobal(window->rect().center()); shutdownWindow->move(global.x() - shutdownWindow->width() / 2, global.y() - shutdownWindow->height() / 2); shutdownWindow->show(); + return shutdownWindow; } void ShutdownWindow::closeEvent(QCloseEvent *event) |