Improve and expand QShortcutMap debug output
- Replace vague symbols with descriptive words. - Use qScopeGuard() to ensure that removeShortcut prints the number of removed shortcuts for all execution paths. Change-Id: I4d36366445756b41b1dc40bbb1e987dce669a723 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
fccd419dd6
commit
b1d750d59b
@ -47,6 +47,7 @@
|
|||||||
#include "qwindow.h"
|
#include "qwindow.h"
|
||||||
#include <private/qkeymapper_p.h>
|
#include <private/qkeymapper_p.h>
|
||||||
#include <QtCore/qloggingcategory.h>
|
#include <QtCore/qloggingcategory.h>
|
||||||
|
#include <QtCore/qscopeguard.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ int QShortcutMap::addShortcut(QObject *owner, const QKeySequence &key, Qt::Short
|
|||||||
d->sequences.insert(it, newEntry); // Insert sorted
|
d->sequences.insert(it, newEntry); // Insert sorted
|
||||||
qCDebug(lcShortcutMap).nospace()
|
qCDebug(lcShortcutMap).nospace()
|
||||||
<< "QShortcutMap::addShortcut(" << owner << ", "
|
<< "QShortcutMap::addShortcut(" << owner << ", "
|
||||||
<< key << ", " << context << ") = " << d->currentId;
|
<< key << ", " << context << ") added shortcut with ID " << d->currentId;
|
||||||
return d->currentId;
|
return d->currentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +188,12 @@ int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key
|
|||||||
bool allKeys = key.isEmpty();
|
bool allKeys = key.isEmpty();
|
||||||
bool allIds = id == 0;
|
bool allIds = id == 0;
|
||||||
|
|
||||||
|
auto debug = qScopeGuard([&](){
|
||||||
|
qCDebug(lcShortcutMap).nospace()
|
||||||
|
<< "QShortcutMap::removeShortcut(" << id << ", " << owner << ", "
|
||||||
|
<< key << ") removed " << itemsRemoved << " shortcuts(s)";
|
||||||
|
});
|
||||||
|
|
||||||
// Special case, remove everything
|
// Special case, remove everything
|
||||||
if (allOwners && allKeys && allIds) {
|
if (allOwners && allKeys && allIds) {
|
||||||
itemsRemoved = d->sequences.size();
|
itemsRemoved = d->sequences.size();
|
||||||
@ -209,9 +216,6 @@ int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key
|
|||||||
return itemsRemoved;
|
return itemsRemoved;
|
||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
qCDebug(lcShortcutMap).nospace()
|
|
||||||
<< "QShortcutMap::removeShortcut(" << id << ", " << owner << ", "
|
|
||||||
<< key << ") = " << itemsRemoved;
|
|
||||||
return itemsRemoved;
|
return itemsRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user