From efbda5eaa74dfe1ed81c2973c0fbcdf5c97666dc Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Mon, 1 Sep 2025 16:48:06 +0200 Subject: DolphinContextMenu: Don't parent new file menu to the menu It needs to outlive the menu for the file name input prompt to work. While at it, hook up the new rejected signals ot ensure the menu is properly cleaned up also when canceled. Amends commit 697d58e9 --- src/dolphincontextmenu.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/dolphincontextmenu.cpp') diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 382b4bc7d..1edbca05f 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -214,12 +214,15 @@ void DolphinContextMenu::addDirectoryItemContextMenu() // set up 'Create New' menu QAction *newDirAction = m_mainWindow->actionCollection()->action(QStringLiteral("create_dir")); QAction *newFileAction = m_mainWindow->actionCollection()->action(QStringLiteral("create_file")); - DolphinNewFileMenu *newFileMenu = new DolphinNewFileMenu(newDirAction, newFileAction, this); + // Do not parent this to the menu, it has to outlive it. It is deleted manually below once a file has been created. + DolphinNewFileMenu *newFileMenu = new DolphinNewFileMenu(newDirAction, newFileAction, m_mainWindow); newFileMenu->checkUpToDate(); newFileMenu->setWorkingDirectory(m_fileInfo.url()); newFileMenu->setEnabled(selectedItemsProps.supportsWriting()); connect(newFileMenu, &DolphinNewFileMenu::fileCreated, newFileMenu, &DolphinNewFileMenu::deleteLater); + connect(newFileMenu, &DolphinNewFileMenu::fileCreationRejected, newFileMenu, &DolphinNewFileMenu::deleteLater); connect(newFileMenu, &DolphinNewFileMenu::directoryCreated, newFileMenu, &DolphinNewFileMenu::deleteLater); + connect(newFileMenu, &DolphinNewFileMenu::directoryCreationRejected, newFileMenu, &DolphinNewFileMenu::deleteLater); QMenu *menu = newFileMenu->menu(); menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); -- cgit v1.3