subsurface/desktop-widgets/tab-widgets
Berthold Stoeger 396598430b desktop: fix saving of column-widths of device and site tables
Qt's memory management scheme is completely broken and messes
with common expectations.

QObjects are organized as a tree. The children are destroyed
in the destructor of QObject. This means that they are destructed
after the destructor of the parent object has run and its
sub-object were destructed. Obviously, this makes no sense as
the child objects should be able to access their parent at
any time.

To restore the commonly expected deterministic order of
construction and destruction, one might simply do away with
Qt's silly object tree and organise things using classical
subobjects. However, that breaks with the Qt-generated UI
classes: The objects generated by these classes are *not*
destructed with the UI class. Instead, they are attached
to the widget's QObject tree. Thus these are again destructed
*after* the widget! Who comes up with such a scheme?

In our case this means that we cannot have models used for
TableViews as subobjects, because the TableView needs the
model to save the column widths in the destructor. Which,
as detailed above is called *after* the desctructor of the
widget! Thus, turn these models into heap-allocated objects
and add them to the QObject tree.

Funilly, this exposes another insanity of Qt's QObject tree:
Children are destructed in order of construction! One would
expect that if objects are constructed in the sequence
A, B, C one can expect that C can, at any time, access B and A.
Not so in Qt: The destruction order is likewise A, B, C!

Thus, take care to init the widgets before the model. Jeez.

Finally, print a warning in the column-saving code of
TableWidget, so that these kind of subtleties are caught
in the future.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-07 11:37:51 -08:00
..
maintab.cpp revert preference settings for title color 2020-11-04 14:51:55 -08:00
maintab.h desktop: automatically pick a good theme title color 2020-11-04 14:47:10 -08:00
maintab.ui desktop: generalize the colorization of the tab widget 2020-11-03 23:08:39 -08:00
TabBase.cpp desktop: automatically pick a good theme title color 2020-11-04 14:47:10 -08:00
TabBase.h desktop: automatically pick a good theme title color 2020-11-04 14:47:10 -08:00
TabDiveComputer.cpp desktop: fix saving of column-widths of device and site tables 2020-11-07 11:37:51 -08:00
TabDiveComputer.h desktop: fix saving of column-widths of device and site tables 2020-11-07 11:37:51 -08:00
TabDiveComputer.ui desktop: rename table widget in DiveComputerTab to "devices" 2020-11-07 11:37:51 -08:00
TabDiveEquipment.cpp desktop: use current_dive instead of displayed_dive on equipment tab 2020-05-07 08:56:57 -07:00
TabDiveEquipment.h undo: show multiple dive warning when editing equipment 2020-04-07 00:13:35 +02:00
TabDiveEquipment.ui desktop: generalize the colorization of the tab widget 2020-11-03 23:08:39 -08:00
TabDiveExtraInfo.cpp cleanup: generalize ExtraDataModel to display data of any dc 2020-05-07 08:46:15 -07:00
TabDiveExtraInfo.h Cleanup: reinstate override modifiers 2018-09-29 15:23:25 -07:00
TabDiveExtraInfo.ui Cleanup: Move dive-equipment tab into own translation units 2019-04-15 10:30:04 +12:00
TabDiveInformation.cpp revert preference settings for title color 2020-11-04 14:51:55 -08:00
TabDiveInformation.h desktop: automatically pick a good theme title color 2020-11-04 14:47:10 -08:00
TabDiveInformation.ui desktop: generalize the colorization of the tab widget 2020-11-03 23:08:39 -08:00
TabDivePhotos.cpp desktop: use current_dive to save subtitles 2020-05-07 08:56:58 -07:00
TabDivePhotos.h Write dive data as video subtitles 2019-04-16 20:38:19 +02:00
TabDivePhotos.ui Implement different zoom levels for dive photos tab 2017-12-18 12:07:10 -08:00
TabDiveSite.cpp desktop: fix saving of column-widths of device and site tables 2020-11-07 11:37:51 -08:00
TabDiveSite.h desktop: fix saving of column-widths of device and site tables 2020-11-07 11:37:51 -08:00
TabDiveSite.ui desktop: generalize the colorization of the tab widget 2020-11-03 23:08:39 -08:00
TabDiveStatistics.cpp desktop: allow update of tab widget colors at run time 2020-11-03 23:08:39 -08:00
TabDiveStatistics.h desktop: move MinMaxAvgWidget to TabDiveStatistics 2020-10-26 20:56:56 -07:00
TabDiveStatistics.ui Reorganise the current statistics tab 2020-11-04 11:34:26 -08:00