Commit d1bab199 authored by Don Gagne's avatar Don Gagne

Fix shutdown sequence

parent 23e9acf2
......@@ -85,8 +85,7 @@ const char* QGCApplication::_savedFileParameterDirectoryName = "SavedParameters"
QGCApplication::QGCApplication(int &argc, char* argv[]) :
QApplication(argc, argv),
_mainWindow(NULL)
QApplication(argc, argv)
{
Q_ASSERT(_app == NULL);
_app = this;
......@@ -133,7 +132,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[]) :
QGCApplication::~QGCApplication()
{
destroySingletonsForUnitTest();
delete _mainWindow;
}
void QGCApplication::_initCommon(void)
......@@ -216,12 +214,12 @@ bool QGCApplication::_initForNormalAppBoot(void)
// Start the user interface
splashScreen->showMessage(tr("Starting user interface"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
_mainWindow = new MainWindow(splashScreen, mode);
Q_CHECK_PTR(_mainWindow);
MainWindow* mainWindow = new MainWindow(splashScreen, mode);
Q_CHECK_PTR(mainWindow);
UDPLink* udpLink = NULL;
if (_mainWindow->getCustomMode() == MainWindow::CUSTOM_MODE_WIFI)
if (mainWindow->getCustomMode() == MainWindow::CUSTOM_MODE_WIFI)
{
// Connect links
// to make sure that all components are initialized when the
......@@ -241,8 +239,8 @@ bool QGCApplication::_initForNormalAppBoot(void)
#endif
// Remove splash screen
splashScreen->finish(_mainWindow);
_mainWindow->splashScreenFinished();
splashScreen->finish(mainWindow);
mainWindow->splashScreenFinished();
// If we made it this far and we still don't have a location. Either the specfied location was invalid
// or we coudn't create a default location. Either way, we need to let the user know and prompt for a new
......@@ -250,11 +248,11 @@ bool QGCApplication::_initForNormalAppBoot(void)
if (savedFilesLocation.isEmpty()) {
QGCMessageBox::warning(tr("Bad save location"),
tr("The location to save files to is invalid, or cannot be written to. Please provide a new one."));
_mainWindow->showSettings();
mainWindow->showSettings();
}
if (settingsUpgraded) {
_mainWindow->showInfoMessage(tr("Settings Cleared"),
mainWindow->showInfoMessage(tr("Settings Cleared"),
tr("The format for QGroundControl saved settings has been modified. "
"Your saved settings have been reset to defaults."));
}
......@@ -270,7 +268,7 @@ bool QGCApplication::_initForNormalAppBoot(void)
if (button == QMessageBox::Yes)
{
//mainWindow->close();
QTimer::singleShot(200, _mainWindow, SLOT(close()));
QTimer::singleShot(200, mainWindow, SLOT(close()));
}
}
......@@ -402,9 +400,8 @@ void QGCApplication::destroySingletonsForUnitTest(void)
singleton->deleteInstance();
}
if (_mainWindow) {
_mainWindow->deleteInstance();
_mainWindow = NULL;
if (MainWindow::instance()) {
delete MainWindow::instance();
}
_singletons.clear();
......
......@@ -120,8 +120,6 @@ private:
static const char* _defaultSavedFileDirectoryName; ///< Default name for user visible save file directory
static const char* _savedFileMavlinkLogDirectoryName; ///< Name of mavlink log subdirectory
static const char* _savedFileParameterDirectoryName; ///< Name of parameter subdirectory
MainWindow* _mainWindow;
QList<QGCSingleton*> _singletons; ///< List of registered global singletons
};
......
......@@ -161,5 +161,7 @@ int main(int argc, char *argv[])
delete app;
qDebug() << "After app delete";
return exitCode;
}
......@@ -101,17 +101,12 @@ MainWindow* MainWindow::_create(QSplashScreen* splashScreen, enum MainWindow::CU
MainWindow* MainWindow::instance(void)
{
// QGCAppication should have already called _create. Singleton is only created by call to _create
// not here.
Q_ASSERT(_instance);
return _instance;
}
void MainWindow::deleteInstance(void)
{
delete _instance;
_instance = NULL;
delete this;
}
/// @brief Private constructor for MainWindow. MainWindow singleton is only ever created
......@@ -416,6 +411,8 @@ MainWindow::~MainWindow()
{
commsWidgetList[i]->deleteLater();
}
_instance = NULL;
}
void MainWindow::resizeEvent(QResizeEvent * event)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment