diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index fc008267a7c04431fb9dbf274653af4a1965286d..f92f9526d2f9894ca9d0bc3104c69491b2fb8bb5 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -634,12 +634,16 @@ void MainWindow::closeEvent(QCloseEvent *event) tr("There are still active connections to vehicles. Do you want to disconnect these before closing?"), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); - if (button == QMessageBox::Yes) { - LinkManager::instance()->disconnectAll(); - } else { - event->ignore(); - return; - } + if (button == QMessageBox::Yes) { + LinkManager::instance()->disconnectAll(); + // The above disconnect causes a flurry of activity as the vehicle components are removed. This in turn + // causes the Windows Version of Qt to crash if you allow the close event to be accepted. In order to prevent + // the crash, we ignore the close event and setup a delayed timer to close the window after things settle down. + QTimer::singleShot(1500, this, &MainWindow::_closeWindow); + } + + event->ignore(); + return; } // This will process any remaining flight log save dialogs diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index c2923fccb7af9ddca581faeb2192f1c942ed2667..021cd0e824ce90f4f9f6497a6e544ef5df457eb6 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -287,7 +287,8 @@ private slots: #ifdef UNITTEST_BUILD void _showQmlTestWidget(void); #endif - + void _closeWindow(void) { close(); } + private: /// Constructor is private since all creation should be through MainWindow::_create MainWindow(QSplashScreen* splashScreen);