Browse Source

Fix shutdown crash

QGC4.4
Don Gagne 8 years ago
parent
commit
d89f6b7994
  1. 11
      src/QGCApplication.cc
  2. 6
      src/QGCApplication.h
  3. 1
      src/main.cc

11
src/QGCApplication.cc

@ -334,8 +334,12 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) @@ -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() @@ -346,6 +350,11 @@ QGCApplication::~QGCApplication()
delete _toolbox;
}
QGCApplication::~QGCApplication()
{
// Place shutdown code in _shutdown
}
void QGCApplication::_initCommon(void)
{
QSettings settings;

6
src/QGCApplication.h

@ -152,6 +152,12 @@ public: @@ -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);

1
src/main.cc

@ -253,6 +253,7 @@ int main(int argc, char *argv[]) @@ -253,6 +253,7 @@ int main(int argc, char *argv[])
exitCode = app->exec();
}
app->_shutdown();
delete app;
//-- Shutdown Cache System
destroyMapEngine();

Loading…
Cancel
Save