]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/disabledactionnotifier.cpp
SVN_SILENT made messages (.desktop file) - always resolve ours
[dolphin.git] / src / disabledactionnotifier.cpp
index 844e66228ece65c81cd8b809517cecb61099f9c8..0b83a9664e93ab37d04dfcdb48990c12268587ae 100644 (file)
@@ -18,17 +18,22 @@ void DisabledActionNotifier::setDisabledReason(QAction *action, QStringView reas
     }
 
     if (m_shortcuts.contains(action)) {
-        m_shortcuts.take(action)->deleteLater();
+        clearDisabledReason(action);
     }
 
     QShortcut *shortcut = new QShortcut(action->shortcut(), parent());
     m_shortcuts.insert(action, shortcut);
 
-    connect(action, &QAction::enabledChanged, this, [this, action](bool enabled) {
-        if (enabled) {
-            m_shortcuts.take(action)->deleteLater();
-        }
-    });
+    connect(
+        action,
+        &QAction::enabledChanged,
+        this,
+        [this, action](bool enabled) {
+            if (enabled && m_shortcuts.contains(action)) {
+                m_shortcuts.take(action)->deleteLater();
+            }
+        },
+        Qt::SingleShotConnection);
 
     // Don't capture QStringView, as it may reference a temporary QString
     QString reasonString = reason.toString();
@@ -43,6 +48,7 @@ void DisabledActionNotifier::clearDisabledReason(QAction *action)
         return;
     }
 
+    action->disconnect(this);
     if (m_shortcuts.contains(action)) {
         m_shortcuts.take(action)->deleteLater();
     }