aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Tillmanns <marcus.tillmanns@qt.io>2023-06-08 07:34:56 +0200
committerMarcus Tillmanns <marcus.tillmanns@qt.io>2023-06-08 06:24:33 +0000
commitf83fb72af8c8c872b6a55f8d8d53db41d819ad7b (patch)
treecd9a5f1460e067f9a04ccaf1ea9e29c56c0244d6
parent4e000b87312fa35b6fd8f7262c09c58ecfc179ee (diff)
Terminal: Fix assertv11.0.0-beta1
ShortCutMap::addShortCut did assert if the keysequence was empty. Changed Q_ASSERT to QTC_ASSERT to not crash. Change-Id: Ib03e21bb00ab989e00d5c3de68b52b84c6eb2360 Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r--src/plugins/terminal/shortcutmap.cpp13
-rw-r--r--src/plugins/terminal/terminalwidget.cpp10
2 files changed, 14 insertions, 9 deletions
diff --git a/src/plugins/terminal/shortcutmap.cpp b/src/plugins/terminal/shortcutmap.cpp
index 7a63a087f6..72023e808a 100644
--- a/src/plugins/terminal/shortcutmap.cpp
+++ b/src/plugins/terminal/shortcutmap.cpp
@@ -5,6 +5,8 @@
#include "shortcutmap.h"
+#include <utils/qtcassert.h>
+
#include <algorithm>
#include <QGuiApplication>
@@ -125,8 +127,9 @@ int ShortcutMap::addShortcut(QObject *owner,
Qt::ShortcutContext context,
ContextMatcher matcher)
{
- Q_ASSERT_X(owner, "ShortcutMap::addShortcut", "All shortcuts need an owner");
- Q_ASSERT_X(!key.isEmpty(), "ShortcutMap::addShortcut", "Cannot add keyless shortcuts to map");
+ QTC_ASSERT(owner, return 0); // "ShortcutMap::addShortcut", "All shortcuts need an owner");
+ QTC_ASSERT(!key.isEmpty(),
+ return 0); // "ShortcutMap::addShortcut", "Cannot add keyless shortcuts to map");
Q_D(ShortcutMap);
ShortcutEntry newEntry(owner, key, context, --(d->currentId), true, matcher);
@@ -327,9 +330,9 @@ QKeySequence::SequenceMatch ShortcutMap::find(QKeyEvent *e, int ignoredModifiers
// Should never happen
if (d->newEntries == d->currentSequences) {
- Q_ASSERT_X(e->key() != Qt::Key_unknown || e->text().size(),
- "ShortcutMap::find",
- "New sequence to find identical to previous");
+ QTC_ASSERT(e->key() != Qt::Key_unknown || e->text().size(), return QKeySequence::NoMatch);
+ //"ShortcutMap::find",
+ // "New sequence to find identical to previous");
return QKeySequence::NoMatch;
}
diff --git a/src/plugins/terminal/terminalwidget.cpp b/src/plugins/terminal/terminalwidget.cpp
index 91905c99d4..6753047369 100644
--- a/src/plugins/terminal/terminalwidget.cpp
+++ b/src/plugins/terminal/terminalwidget.cpp
@@ -262,10 +262,12 @@ void TerminalWidget::registerShortcut(Command *cmd)
QTC_ASSERT(cmd, return);
auto addShortCut = [this, cmd] {
for (const auto &keySequence : cmd->keySequences()) {
- m_shortcutMap.addShortcut(cmd->action(),
- keySequence,
- Qt::ShortcutContext::WindowShortcut,
- contextMatcher);
+ if (!keySequence.isEmpty()) {
+ m_shortcutMap.addShortcut(cmd->action(),
+ keySequence,
+ Qt::ShortcutContext::WindowShortcut,
+ contextMatcher);
+ }
}
};
auto removeShortCut = [this, cmd] { m_shortcutMap.removeShortcut(0, cmd->action()); };