┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/disabledactionnotifier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/disabledactionnotifier.cpp')
-rw-r--r--src/disabledactionnotifier.cpp18
1 files changed, 12 insertions, 6 deletions
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();
}