Commit d89f6b79 authored by Don Gagne's avatar Don Gagne

Fix shutdown crash

parent cda355d6
......@@ -334,8 +334,12 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
_toolbox->setChildToolboxes();
}
QGCApplication::~QGCApplication()
void QGCApplication::_shutdown(void)
{
// This code is specifically not in the destructor since the application object may not be available in the destructor.
// This cause problems for deleting object like settings which are in the toolbox which may have qml references. By
// moving them here and having main.cc call this prior to deleting the app object we make sure app object is still
// around while these things are shutting down.
#ifndef __mobile__
MainWindow* mainWindow = MainWindow::instance();
if (mainWindow) {
......@@ -346,6 +350,11 @@ QGCApplication::~QGCApplication()
delete _toolbox;
}
QGCApplication::~QGCApplication()
{
// Place shutdown code in _shutdown
}
void QGCApplication::_initCommon(void)
{
QSettings settings;
......
......@@ -152,6 +152,12 @@ public:
static QGCApplication* _app; ///< Our own singleton. Should be reference directly by qgcApp
public:
// Although public, these methods are internal and should only be called by UnitTest code
/// Shutdown the application object
void _shutdown(void);
private slots:
void _missingParamsDisplay(void);
......
......@@ -253,6 +253,7 @@ int main(int argc, char *argv[])
exitCode = app->exec();
}
app->_shutdown();
delete app;
//-- Shutdown Cache System
destroyMapEngine();
......
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