|
54 | 54 | #include <QThread> |
55 | 55 | #include <QTimer> |
56 | 56 | #include <QTranslator> |
| 57 | +#include <QWindow> |
57 | 58 |
|
58 | 59 | #if defined(QT_STATICPLUGIN) |
59 | 60 | #include <QtPlugin> |
@@ -258,6 +259,7 @@ void BitcoinApplication::createOptionsModel(bool resetSettings) |
258 | 259 | void BitcoinApplication::createWindow(const NetworkStyle *networkStyle) |
259 | 260 | { |
260 | 261 | window = new BitcoinGUI(node(), platformStyle, networkStyle, nullptr); |
| 262 | + connect(window, &BitcoinGUI::quitClicked, this, &BitcoinApplication::requestShutdown); |
261 | 263 |
|
262 | 264 | pollShutdownTimer = new QTimer(window); |
263 | 265 | connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown); |
@@ -325,13 +327,17 @@ void BitcoinApplication::requestInitialize() |
325 | 327 |
|
326 | 328 | void BitcoinApplication::requestShutdown() |
327 | 329 | { |
| 330 | + for (const auto w : QGuiApplication::topLevelWindows()) { |
| 331 | + w->hide(); |
| 332 | + } |
| 333 | + |
328 | 334 | // Show a simple window indicating shutdown status |
329 | 335 | // Do this first as some of the steps may take some time below, |
330 | 336 | // for example the RPC console may still be executing a command. |
331 | 337 | shutdownWindow.reset(ShutdownWindow::showShutdownWindow(window)); |
332 | 338 |
|
333 | 339 | qDebug() << __func__ << ": Requesting shutdown"; |
334 | | - window->hide(); |
| 340 | + |
335 | 341 | // Must disconnect node signals otherwise current thread can deadlock since |
336 | 342 | // no event loop is running. |
337 | 343 | window->unsubscribeFromCoreSignals(); |
@@ -408,13 +414,13 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead |
408 | 414 | pollShutdownTimer->start(200); |
409 | 415 | } else { |
410 | 416 | Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown |
411 | | - quit(); // Exit first main loop invocation |
| 417 | + requestShutdown(); |
412 | 418 | } |
413 | 419 | } |
414 | 420 |
|
415 | 421 | void BitcoinApplication::shutdownResult() |
416 | 422 | { |
417 | | - quit(); // Exit second main loop invocation after shutdown finished |
| 423 | + quit(); |
418 | 424 | } |
419 | 425 |
|
420 | 426 | void BitcoinApplication::handleRunawayException(const QString &message) |
@@ -637,8 +643,6 @@ int GuiMain(int argc, char* argv[]) |
637 | 643 | #if defined(Q_OS_WIN) |
638 | 644 | WinShutdownMonitor::registerShutdownBlockReason(QObject::tr("%1 didn't yet exit safely…").arg(PACKAGE_NAME), (HWND)app.getMainWinId()); |
639 | 645 | #endif |
640 | | - app.exec(); |
641 | | - app.requestShutdown(); |
642 | 646 | app.exec(); |
643 | 647 | rv = app.getReturnValue(); |
644 | 648 | } else { |
|
0 commit comments