[frameworks/kxmlgui] src: Avoid duplicate aboutToShow connections on the Settings menu

David Faure <[email protected]> Wed, 5 Aug 2026 11:39:20 +0000 (UTC)
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 81b6d2c5b2641836c3d506d85bf50c350ed120a3 by David Faure.
Committed on 05/08/2026 at 11:35.
Pushed by dfaure into branch 'master'.

Avoid duplicate aboutToShow connections on the Settings menu

setupActions() reconnects to the menu every time it rebuilds, which happens on
every clientAdded. In Konsole that is every tab switch, so the connections pile
up: opening the Settings menu then runs setupActions() - and its recursive
findChildren<KToolBar*>() over the whole window - once per accumulated
connection. After a day of use that takes seconds.

M  +3    -1    src/ktoolbarhandler.cpp

https://invent.kde.org/frameworks/kxmlgui/-/commit/81b6d2c5b2641836c3d506d85bf50c350ed120a3

diff --git a/src/ktoolbarhandler.cpp b/src/ktoolbarhandler.cpp
index 154769cd..7f39c5b0 100644
--- a/src/ktoolbarhandler.cpp
+++ b/src/ktoolbarhandler.cpp
@@ -192,7 +192,9 @@ void ToolBarHandler::Private::connectToActionContainer(QWidget *container)
         return;
     }
 
-    connect(popupMenu, &QMenu::aboutToShow, parent, &ToolBarHandler::setupActions);
+    // Unique, otherwise a duplicate connection is added on every rebuild, i.e. on
+    // every GUI client change (i.e. every tab switch in Konsole).
+    connect(popupMenu, &QMenu::aboutToShow, parent, &ToolBarHandler::setupActions, Qt::UniqueConnection);
 }
 
 ToolBarHandler::ToolBarHandler(KXmlGuiWindow *mainWindow)