QWeakPointer a QPointer (+comment) to make it clear, that we must track the lifetime of the context menu instead of doing "only" out of scope deleting.
Thanks to Frank for pointing out this problem!
CCMAIL: frank78ac@googlemail.com
const QUrl& url,
const QList<QAction*>& customActions)
{
- QScopedPointer<DolphinContextMenu> contextMenu(new DolphinContextMenu(this, pos, item, url));
+ QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
contextMenu.data()->setCustomActions(customActions);
const DolphinContextMenu::Command command = contextMenu.data()->open();
default:
break;
}
+
+ // Delete the menu, unless it has been deleted in its own nested event loop already.
+ if (contextMenu) {
+ contextMenu->deleteLater();
+ }
}
void DolphinMainWindow::updateControlMenu()