From 99f2faa7e9a532aac4d8dc2d306fb64ef7a29743 Mon Sep 17 00:00:00 2001 From: Stefan Dunca <stefan@auterion.com> Date: Tue, 5 Nov 2019 12:09:22 +0100 Subject: [PATCH] Fix crash when enabling Advanced Tuning Disable closing app on last window close. This will close the app on every widget spawned in QML that closes (MessageBox) --- .../APM/APMTuningComponentCopter.qml | 4 ++-- .../PX4/PX4TuningComponentCopter.qml | 4 ++-- .../PX4/PX4TuningComponentPlane.qml | 4 ++-- src/QGCApplication.cc | 7 ++++--- src/QGCApplication.h | 20 ++++++++++++++++++- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml b/src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml index 0aab67e70f..5899c988d6 100644 --- a/src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml +++ b/src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml @@ -64,8 +64,8 @@ SetupPage { ExclusiveGroup { id: returnAltRadioGroup } Component.onCompleted: { - // Advanced tuning is hacked out due to Qt crash with Qml Charts and a QGuiApplication - //showAdvanced = !ScreenTools.isMobile + // We use QtCharts only on Desktop platforms + showAdvanced = !ScreenTools.isMobile // Qml Sliders have a strange behavior in which they first set Slider::value to some internal // setting and then set Slider::value to the bound properties value. If you have an onValueChanged diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml index 08960962f8..3041a311cb 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml @@ -29,8 +29,8 @@ SetupPage { width: availableWidth Component.onCompleted: { - // Advanced tuning is hacked out due to Qt crash with Qml Charts and a QGuiApplication - //showAdvanced = !ScreenTools.isMobile + // We use QtCharts only on Desktop platforms + showAdvanced = !ScreenTools.isMobile } FactPanelController { diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml index 7d91990c0a..92ee1bee14 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml @@ -29,8 +29,8 @@ SetupPage { width: availableWidth Component.onCompleted: { - // Advanced tuning is hacked out due to Qt crash with Qml Charts and a QGuiApplication - //showAdvanced = !ScreenTools.isMobile + // We use QtCharts only on Desktop platforms + showAdvanced = !ScreenTools.isMobile } FactPanelController { diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index c2b744209e..22e2931547 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -158,7 +158,11 @@ static QObject* shapeFileHelperSingletonFactory(QQmlEngine*, QJSEngine*) } QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) + #if defined(__mobile__) : QGuiApplication (argc, argv) + #else + : QApplication (argc, argv) + #endif , _runningUnitTests (unitTesting) { _app = this; @@ -555,9 +559,6 @@ bool QGCApplication::_initForNormalAppBoot() QSettings settings; - // Exit main application when last window is closed - connect(this, &QGCApplication::lastWindowClosed, this, QGCApplication::quit); - _qmlAppEngine = toolbox()->corePlugin()->createRootWindow(this); // Safe to show popup error messages now that main window is created diff --git a/src/QGCApplication.h b/src/QGCApplication.h index 364da2d108..9bd19f75bc 100644 --- a/src/QGCApplication.h +++ b/src/QGCApplication.h @@ -35,7 +35,25 @@ class QGCSingleton; class QGCToolbox; class QGCFileDownload; -class QGCApplication : public QGuiApplication +/** + * @brief The main application and management class. + * + * This class is started by the main method and provides + * the central management unit of the groundstation application. + * + * Needs QApplication base to support QtCharts module. This way + * we avoid application crashing on 5.12 when using the module. + * We don't have QtWidgets on mobile, avoid using it. + * + * Note: `lastWindowClosed` will be sent by MessageBox popups and other + * dialogs, that are spawned in QML, when they are closed +**/ +class QGCApplication : + #if defined(__mobile__) + public QGuiApplication + #else + public QApplication + #endif { Q_OBJECT -- GitLab