From 44973c9dd016569e643a73148c32bd1a0b01d71d Mon Sep 17 00:00:00 2001 From: Sebastian Englbrecht Date: Sun, 31 May 2026 18:59:36 +0200 Subject: dolphinmainwindow,dolphinview: clarify QPointer semantics around exec() exec() runs a nested event loop that can destroy the parent widget, so the post-exec null-check on the QPointer is intentional, not redundant. dolphinmainwindow: replace `if (contextMenu) deleteLater()` with `delete contextMenu`. QPointer returns nullptr for a destroyed object, making delete a safe no-op. dolphinview: capture the menu as a raw pointer for pre-exec setup; reserve the QPointer for the post-exec liveness check and deletion. --- src/dolphinmainwindow.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/dolphinmainwindow.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 439db8293..c1bbcc5f5 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1522,11 +1522,7 @@ void DolphinMainWindow::openContextMenu(const QPoint &pos, const KFileItem &item { QPointer contextMenu = new DolphinContextMenu(this, item, selectedItems, url, m_fileItemActions); contextMenu->exec(pos); - - // Delete the menu, unless it has been deleted in its own nested event loop already. - if (contextMenu) { - contextMenu->deleteLater(); - } + delete contextMenu; } QMenu *DolphinMainWindow::createPopupMenu() -- cgit v1.3.1