X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/7d49cb567b595570f59156965332428c9490a04d..697d58e9727e229abb81956d27a05d1f02d8c775:/src/disabledactionnotifier.cpp diff --git a/src/disabledactionnotifier.cpp b/src/disabledactionnotifier.cpp index 844e66228..0b83a9664 100644 --- a/src/disabledactionnotifier.cpp +++ b/src/disabledactionnotifier.cpp @@ -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(); }