[OS X] avoid crashing KNode when unsubscribing from a group

Review Request #124061 - Created June 10, 2015 and submitted

Information
René J.V. Bertin
kdepim
4.14
Reviewers
kde-mac, kdepim

On OS X, unsubscribing from a group with the context menu's action item (right-click on group, unsubscribe) leads to a crash systematically. Analysis of the (huge) backtrace shows that this is because a (pending?) redraw event is sent (by qApp->processEvents() in KNMainWidget::secureProcessEvents) to the group entry after it has already been deleted. (The pending event is likely to be an expose event queued when the context menu closed.)
Normally one would avoid this situation by using deleteLater() instead of the direct delete, but since KNCollectionViewItem does not inherit QObject a workaround is needed.
The attached patch implements a solution that to prevents the crashing in my testing. It disables the item to be removed in addition to setting it hidden, then updates the list (setListItem(0)), group and calls qApp->processEvents() explicitly before it is called in KNMainWidget::secureProcessEvents() so that pending events are processed first. The item is deleted only after those steps.

I decided not to make this modification specific to OS X (Q_OS_MAC) because it should not have undesirable side-effects elsewhere (and there may be other platforms where similar pending-events occur).

On Mac OS X 10.9.5 with KDELibs 4.14.7 and kdepim 4.13.3 (the patched function has not changed since that version).

Daniel Vrátil
René J.V. Bertin
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit 217000009a9cb538bda53e14bbe8315014fb2b14 by René J.V. Bertin to branch KDE/4.14.
Loading...