[PATCH] applets/notifications: Don't set a parent for WidgetsAskUserActionHandler
authorKai Uwe Broulik <kde@privat.broulik.de>
Tue, 20 May 2025 16:00:15 +0000 (16:00 +0000)
committerAurélien COUDERC <coucouf@debian.org>
Tue, 20 May 2025 06:31:26 +0000 (08:31 +0200)
The notification popup gets destroyed as soon as the user clicked the menu item,
so the handler is destroyed (curiously still leaving the KMessageDialog up) and
askUserDeleteResult is never emitted.

BUG: 504385

(cherry picked from commit f81dd70a3501f1011d73128277c4aba87014c481)

Co-authored-by: Kai Uwe Broulik <kde@privat.broulik.de>
(cherry picked from commit 7dff2f025da66873911eb1a66fbdded080c7b473)

Co-authored-by: Kai Uwe Broulik <kde@privat.broulik.de>
Gbp-Pq: Name upstream_41a554e6_applets-notifications-Don-t-set-a-parent-for-WidgetsAskUserActionHandler.patch

applets/notifications/filemenu.cpp

index 4bc06cb4c02fc894e247ac0dd2c0c780035b7834..26b9c670d55a0776e823d2a0324a14080b81c67b 100644 (file)
@@ -151,7 +151,8 @@ void FileMenu::open(int x, int y)
     const bool canTrash = itemProperties.isLocal() && itemProperties.supportsMoving();
     if (canTrash) {
         auto moveToTrashLambda = [this] {
-            auto handler = new KIO::WidgetsAskUserActionHandler(this);
+            // No parent since the FileMenu will be destroyed as soon as the user clicked the menu item.
+            auto handler = new KIO::WidgetsAskUserActionHandler();
             connect(handler, &KIO::WidgetsAskUserActionHandler::askUserDeleteResult, [handler](bool allow, const QList<QUrl> &urls) {
                 if (allow) {
                     auto job = KIO::trash(urls);
@@ -172,7 +173,8 @@ void FileMenu::open(int x, int y)
 
     if (itemProperties.supportsDeleting() && (!canTrash || showDeleteCommand)) {
         auto deleteLambda = [this] {
-            auto handler = new KIO::WidgetsAskUserActionHandler(this);
+            // No parent since the FileMenu will be destroyed as soon as the user clicked the menu item.
+            auto handler = new KIO::WidgetsAskUserActionHandler();
             connect(handler, &KIO::WidgetsAskUserActionHandler::askUserDeleteResult, [handler](bool allow, const QList<QUrl> &urls) {
                 if (allow) {
                     auto job = KIO::del(urls);