- 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);