diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index b3d83c11b539e47389ec8c8ac0f7393288d9022c..e80be31f811f6a0dd9f3995affd8eeee1fc2ccf0 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -471,11 +471,17 @@ void MainWindow::closeEvent(QCloseEvent *event) // We have to pull out the QmlWidget from the main window and delete it here, before // the MainWindow ends up getting deleted. Otherwise the Qml has a reference to MainWindow // inside it which in turn causes a shutdown crash. - // Remove image provider - _mainQmlWidgetHolder->getEngine()->removeImageProvider(QLatin1String("QGCImages")); - _centralLayout->removeWidget(_mainQmlWidgetHolder); - delete _mainQmlWidgetHolder; - _mainQmlWidgetHolder = NULL; + + //-- Unit test gets here with _mainQmlWidgetHolder being NULL + + if(_mainQmlWidgetHolder) + { + // Remove image provider + _mainQmlWidgetHolder->getEngine()->removeImageProvider(QLatin1String("QGCImages")); + _centralLayout->removeWidget(_mainQmlWidgetHolder); + delete _mainQmlWidgetHolder; + _mainQmlWidgetHolder = NULL; + } _storeCurrentViewState(); storeSettings();