From 27a4837c700a38d227fc8df0af9edfd180e92cbe Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Sat, 7 Nov 2015 10:46:30 -0500 Subject: [PATCH] Testing for _mainQmlWidgetHolder before blindly assuming it is valid. --- src/ui/MainWindow.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index b3d83c11b5..e80be31f81 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(); -- GitLab