KViewStateSerializer: Fix crash when view is destroyed before state serializer

Authored by cfeck on May 12 2017, 2:13 AM.



According to bug 353380, KViewStateSerializer::restoreScrollBarState() calls QScrollBar::maximum() on an invalid (i.e. already deleted) scrollbar. This means, the enclosing QAbstractScrollArea has been deleted between the call to ::restoreScrollState() and the deferred (via a single shot timer) ::restoreScrollBarState().

This bug had already been reported against the kdelibs4 KViewStateSaver as bug 328755. The commit there (comment #9) was not forward-ported to KWidgetsAddons, but also was not effective, evidenced by the more recent comments.

The actual cause (i.e. the view is destroyed before the state saver) could probably also be fixed in the calling code, but according to LXR, there are many users of ETMViewStateSaver, and I got confused about the comment at https://lxr.kde.org/source/kde/pim/korganizer/src/akonadicollectionview.cpp#0226

This commit works around the issue by allowing users to delete the view immediately after ::restoreScrollState() was called.

Diff Detail

R236 KWidgetsAddons
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
cfeck created this revision.May 12 2017, 2:13 AM
cfeck edited the summary of this revision. (Show Details)
skelly accepted this revision.Jun 1 2017, 11:52 PM
This revision is now accepted and ready to land.Jun 1 2017, 11:52 PM
This revision was automatically updated to reflect the committed changes.