From 0544bcaacd15d83485352ace2e9f5446ed3a948b Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Wed, 20 Apr 2016 15:02:41 -0700 Subject: [PATCH] Simpler cross-platform solution, with comments. --- interface/src/Application.cpp | 6 ------ libraries/ui/src/MainWindow.cpp | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 21cb4c8ec2..4e01fe85c3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -365,12 +365,6 @@ public: return true; } } - - if (message->message == WM_CLOSE) { - // tell our registered application to quit - QMetaObject::invokeMethod(qApp, "quit"); - return true; // Don't zombify the application by OS-exitting. Let the application quit in the normal quit-signal way. - } } return false; } diff --git a/libraries/ui/src/MainWindow.cpp b/libraries/ui/src/MainWindow.cpp index ce23bd02a2..bc67a726bd 100644 --- a/libraries/ui/src/MainWindow.cpp +++ b/libraries/ui/src/MainWindow.cpp @@ -64,6 +64,15 @@ void MainWindow::saveGeometry() { } void MainWindow::closeEvent(QCloseEvent* event) { + // It is the job of Application::quit() to shut things down properly when it is finished with its event loop. + // But if we don't explicitly ignore this event now, the window and application event loop will close + // before we've had a chance to act on the aboutToClose signal. This will leaves a zombie process on all platforms. + // To repro: + // Open a QML modal dialog (e.g., select an avatar to wear), but don't dismiss it. + // Close the application with the operating system window close button (not the menu Quit) + // With ignore: App will wait until you accept or dismiss the dialog and log "Normal exit". + // Without ignore: App will close immediately, and nothing will log about quitting or exit. + event->ignore(); qApp->quit(); }