Terminal: Q_ASSERT workaround

Change-Id: I7e1bf06db437b523e8b06695c3b12f2562a73ce8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-10-27 11:15:39 +02:00
parent cca7bc98a9
commit a3853ecc44

View File

@@ -550,12 +550,18 @@ bool ShortcutMap::dispatchEvent(QKeyEvent *e)
<< "\", " << next->id << ", " << static_cast<bool>(enabledShortcuts > 1) << "\", " << next->id << ", " << static_cast<bool>(enabledShortcuts > 1)
<< ") to object(" << next->owner << ')'; << ") to object(" << next->owner << ')';
} }
QShortcutEvent se(next->keyseq, next->id, enabledShortcuts > 1);
QCoreApplication::sendEvent(const_cast<QObject *>(next->owner), &se);
QAction *action = qobject_cast<QAction *>(next->owner); if (auto action = qobject_cast<QAction *>(next->owner)) {
if (action) // We call the action here ourselves instead of relying on sending a ShortCut event,
// as the action will try to match the shortcut id to the global shortcutmap.
// This triggers an annoying Q_ASSERT when linking against a debug Qt. Calling trigger
// directly circumvents this.
action->trigger();
return action->isEnabled(); return action->isEnabled();
} else {
QShortcutEvent se(next->keyseq, next->id, enabledShortcuts > 1);
QCoreApplication::sendEvent(const_cast<QObject *>(next->owner), &se);
}
return true; return true;
} }