From 23e9acf2a8a1dec3860f547ad88251cf6dea32d6 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 26 Nov 2014 13:59:38 -0800 Subject: [PATCH] Cleanup application object --- src/QGCApplication.cc | 15 ++++++--------- src/main.cc | 10 ++++++++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index fd3dc4dbf..07c5e62cf 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -130,6 +130,12 @@ QGCApplication::QGCApplication(int &argc, char* argv[]) : } +QGCApplication::~QGCApplication() +{ + destroySingletonsForUnitTest(); + delete _mainWindow; +} + void QGCApplication::_initCommon(void) { _createSingletons(); @@ -276,15 +282,6 @@ bool QGCApplication::_initForUnitTests(void) return true; } -/** - * @brief Destructor for the groundstation. It destroys all loaded instances. - * - **/ -QGCApplication::~QGCApplication() -{ - -} - void QGCApplication::deleteAllSettingsNextBoot(void) { QSettings settings; diff --git a/src/main.cc b/src/main.cc index 573ee6edd..6e7d74625 100644 --- a/src/main.cc +++ b/src/main.cc @@ -131,6 +131,8 @@ int main(int argc, char *argv[]) app->_initCommon(); + int exitCode; + #ifdef QT_DEBUG if (runUnitTests) { if (!app->_initForUnitTests()) { @@ -147,13 +149,17 @@ int main(int argc, char *argv[]) { qDebug() << failures << " TESTS FAILED!"; } - return -failures; + exitCode = -failures; } else #endif { if (!app->_initForNormalAppBoot()) { return -1; } - return app->exec(); + exitCode = app->exec(); } + + delete app; + + return exitCode; } -- 2.22.0