mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user