From a3853ecc444ba87506d16dc14cdbdaa1fc269de1 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Fri, 27 Oct 2023 11:15:39 +0200 Subject: [PATCH] Terminal: Q_ASSERT workaround Change-Id: I7e1bf06db437b523e8b06695c3b12f2562a73ce8 Reviewed-by: Eike Ziller Reviewed-by: David Schulz --- src/plugins/terminal/shortcutmap.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/terminal/shortcutmap.cpp b/src/plugins/terminal/shortcutmap.cpp index 436757fd256..4e17f0c35e4 100644 --- a/src/plugins/terminal/shortcutmap.cpp +++ b/src/plugins/terminal/shortcutmap.cpp @@ -550,12 +550,18 @@ bool ShortcutMap::dispatchEvent(QKeyEvent *e) << "\", " << next->id << ", " << static_cast(enabledShortcuts > 1) << ") to object(" << next->owner << ')'; } - QShortcutEvent se(next->keyseq, next->id, enabledShortcuts > 1); - QCoreApplication::sendEvent(const_cast(next->owner), &se); - QAction *action = qobject_cast(next->owner); - if (action) + if (auto action = qobject_cast(next->owner)) { + // 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(); + } else { + QShortcutEvent se(next->keyseq, next->id, enabledShortcuts > 1); + QCoreApplication::sendEvent(const_cast(next->owner), &se); + } return true; }