summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-01-17 22:44:09 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-19 13:59:24 -0800
commited09e6a9097546de33dc48e4af1390efd37adda5 (patch)
treeaa4454d2637d89697da70967918d761bd63582fb /desktop-widgets/mainwindow.h
parent36fa27050c749717e186c8564d88b11bd53a96c8 (diff)
downloadsubsurface-ed09e6a9097546de33dc48e4af1390efd37adda5.tar.gz
Desktop: Make filterWidget2 a subobject of MainWindow
In commit b0556abdd35f96b816ba11e40bf5707abe0c3ebf, the filter-widget and the filter were connected by a direct function call. This led to a rather obscure crash on application-close with Qt 5.12. The crash is due to the Ui::MainWindow class being a sub-object of MainWindow, but the FilterWidget2 being *not* a subobject. What happens is that after calling the MainWindow destructor, the subobjects are destructed, notably the Ui class. Then the base-class destructor is called (which makes sense, as destructors are called in reverse order of constructors). But: the QObject destructor calls hide() on all still existing child-objects according to Qt's object hierarchy, notably the visible FilterWidget2. Now the FilterWidget2, on hiding, updates the MainWindow, which has already destructed all its subobjects. Crash. Prevent this crash by making FilterWidget2 a subobject of MainWindow and thus have it destructed before running the QObject destructor. Alternative ways would be: 1) Use signal/slot() instead of function calls, as these are automatically removed if an object is destroyed. 2) Make the FilterWidget2 subobject a smart-pointer. Thus, we probably wouldn't have to include the corresponding header. 3) Make the FilterWidget2 subobject a plain pointer and delete it explicitly in the constructor. Reported-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/mainwindow.h')
-rw-r--r--desktop-widgets/mainwindow.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h
index a18738de4..d78fc293e 100644
--- a/desktop-widgets/mainwindow.h
+++ b/desktop-widgets/mainwindow.h
@@ -17,6 +17,7 @@
#include "ui_mainwindow.h"
#include "ui_plannerDetails.h"
#include "desktop-widgets/notificationwidget.h"
+#include "desktop-widgets/filterwidget2.h"
#include "core/gpslocation.h"
#include "core/dive.h"
@@ -36,7 +37,6 @@ class ProfileWidget2;
class PlannerDetails;
class PlannerSettingsWidget;
class LocationInformationWidget;
-class FilterWidget2;
typedef std::pair<QByteArray, QVariant> WidgetProperty;
typedef QVector<WidgetProperty> PropertyList;
@@ -186,6 +186,7 @@ slots:
private:
Ui::MainWindow ui;
+ FilterWidget2 filterWidget2;
QAction *actionNextDive;
QAction *actionPreviousDive;
QAction *undoAction;