diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-01-17 22:44:09 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-01-19 13:59:24 -0800 |
commit | ed09e6a9097546de33dc48e4af1390efd37adda5 (patch) | |
tree | aa4454d2637d89697da70967918d761bd63582fb /desktop-widgets/filterwidget2.h | |
parent | 36fa27050c749717e186c8564d88b11bd53a96c8 (diff) | |
download | subsurface-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/filterwidget2.h')
0 files changed, 0 insertions, 0 deletions