[OS X] avoid crashing KNode when unsubscribing from a group
Review Request #124061 - Created June 10, 2015 and submitted
|René J.V. Bertin|
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
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
KNCollectionViewItemdoes not inherit
QObjecta 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).