forked from qt-creator/qt-creator
Terminal: Fix assert
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>
This commit is contained in:
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "shortcutmap.h"
|
#include "shortcutmap.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
@@ -125,8 +127,9 @@ int ShortcutMap::addShortcut(QObject *owner,
|
|||||||
Qt::ShortcutContext context,
|
Qt::ShortcutContext context,
|
||||||
ContextMatcher matcher)
|
ContextMatcher matcher)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(owner, "ShortcutMap::addShortcut", "All shortcuts need an owner");
|
QTC_ASSERT(owner, return 0); // "ShortcutMap::addShortcut", "All shortcuts need an owner");
|
||||||
Q_ASSERT_X(!key.isEmpty(), "ShortcutMap::addShortcut", "Cannot add keyless shortcuts to map");
|
QTC_ASSERT(!key.isEmpty(),
|
||||||
|
return 0); // "ShortcutMap::addShortcut", "Cannot add keyless shortcuts to map");
|
||||||
Q_D(ShortcutMap);
|
Q_D(ShortcutMap);
|
||||||
|
|
||||||
ShortcutEntry newEntry(owner, key, context, --(d->currentId), true, matcher);
|
ShortcutEntry newEntry(owner, key, context, --(d->currentId), true, matcher);
|
||||||
@@ -327,9 +330,9 @@ QKeySequence::SequenceMatch ShortcutMap::find(QKeyEvent *e, int ignoredModifiers
|
|||||||
|
|
||||||
// Should never happen
|
// Should never happen
|
||||||
if (d->newEntries == d->currentSequences) {
|
if (d->newEntries == d->currentSequences) {
|
||||||
Q_ASSERT_X(e->key() != Qt::Key_unknown || e->text().size(),
|
QTC_ASSERT(e->key() != Qt::Key_unknown || e->text().size(), return QKeySequence::NoMatch);
|
||||||
"ShortcutMap::find",
|
//"ShortcutMap::find",
|
||||||
"New sequence to find identical to previous");
|
// "New sequence to find identical to previous");
|
||||||
return QKeySequence::NoMatch;
|
return QKeySequence::NoMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -262,11 +262,13 @@ void TerminalWidget::registerShortcut(Command *cmd)
|
|||||||
QTC_ASSERT(cmd, return);
|
QTC_ASSERT(cmd, return);
|
||||||
auto addShortCut = [this, cmd] {
|
auto addShortCut = [this, cmd] {
|
||||||
for (const auto &keySequence : cmd->keySequences()) {
|
for (const auto &keySequence : cmd->keySequences()) {
|
||||||
|
if (!keySequence.isEmpty()) {
|
||||||
m_shortcutMap.addShortcut(cmd->action(),
|
m_shortcutMap.addShortcut(cmd->action(),
|
||||||
keySequence,
|
keySequence,
|
||||||
Qt::ShortcutContext::WindowShortcut,
|
Qt::ShortcutContext::WindowShortcut,
|
||||||
contextMatcher);
|
contextMatcher);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
auto removeShortCut = [this, cmd] { m_shortcutMap.removeShortcut(0, cmd->action()); };
|
auto removeShortCut = [this, cmd] { m_shortcutMap.removeShortcut(0, cmd->action()); };
|
||||||
addShortCut();
|
addShortCut();
|
||||||
|
Reference in New Issue
Block a user