Debugger: Keep watchers alphabetically ordered

Task-number: QTCREATORBUG-12308
Change-Id: Ifdffa20f3ccec6aa2c086ce83db3b4a8817e08ab
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2016-11-29 15:27:38 +01:00
parent 24ae8e0491
commit d583469249
3 changed files with 8 additions and 11 deletions

View File

@@ -1254,8 +1254,6 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters)
runCommand(cmd); runCommand(cmd);
} else { } else {
typedef QHash<QString, int> WatcherHash;
const bool partialUpdate = !updateParameters.partialVariable.isEmpty(); const bool partialUpdate = !updateParameters.partialVariable.isEmpty();
const bool isWatch = isWatchIName(updateParameters.partialVariable); const bool isWatch = isWatchIName(updateParameters.partialVariable);
@@ -1325,10 +1323,9 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters)
if (!partialUpdate) if (!partialUpdate)
str << blankSeparator << "-W"; str << blankSeparator << "-W";
if (!partialUpdate || isWatch) { if (!partialUpdate || isWatch) {
const WatcherHash watcherHash = WatchHandler::watcherNames(); const QMap<QString, int> watchers = WatchHandler::watcherNames();
if (!watcherHash.isEmpty()) { if (!watchers.isEmpty()) {
const WatcherHash::const_iterator cend = watcherHash.constEnd(); for (auto it = watchers.constBegin(), cend = watchers.constEnd(); it != cend; ++it) {
for (WatcherHash::const_iterator it = watcherHash.constBegin(); it != cend; ++it) {
str << blankSeparator << "-w " << "watch." + QString::number(it.value()) str << blankSeparator << "-w " << "watch." + QString::number(it.value())
<< " \"" << it.key() << '"'; << " \"" << it.key() << '"';
} }

View File

@@ -88,7 +88,7 @@ enum { debugModel = 0 };
#define MODEL_DEBUG(s) do { if (debugModel) qDebug() << s; } while (0) #define MODEL_DEBUG(s) do { if (debugModel) qDebug() << s; } while (0)
static QHash<QString, int> theWatcherNames; static QMap<QString, int> theWatcherNames; // Keep order, QTCREATORBUG-12308.
static int theWatcherCount = 0; static int theWatcherCount = 0;
static QHash<QString, int> theTypeFormats; static QHash<QString, int> theTypeFormats;
static QHash<QString, int> theIndividualFormats; static QHash<QString, int> theIndividualFormats;
@@ -2313,7 +2313,7 @@ QStringList WatchHandler::watchedExpressions()
{ {
// Filter out invalid watchers. // Filter out invalid watchers.
QStringList watcherNames; QStringList watcherNames;
QHashIterator<QString, int> it(theWatcherNames); QMapIterator<QString, int> it(theWatcherNames);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
const QString &watcherName = it.key(); const QString &watcherName = it.key();
@@ -2517,7 +2517,7 @@ void WatchHandler::appendWatchersAndTooltipRequests(DebuggerCommand *cmd)
foreach (const DebuggerToolTipContext &p, toolTips) foreach (const DebuggerToolTipContext &p, toolTips)
watchers.append(watcher(p.iname, p.expression)); watchers.append(watcher(p.iname, p.expression));
QHashIterator<QString, int> it(WatchHandler::watcherNames()); QMapIterator<QString, int> it(WatchHandler::watcherNames());
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
watchers.append(watcher("watch." + QString::number(it.value()), it.key())); watchers.append(watcher("watch." + QString::number(it.value()), it.key()));
@@ -2576,7 +2576,7 @@ void WatchHandler::setCurrentItem(const QString &iname)
} }
} }
QHash<QString, int> WatchHandler::watcherNames() QMap<QString, int> WatchHandler::watcherNames()
{ {
return theWatcherNames; return theWatcherNames;
} }

View File

@@ -82,7 +82,7 @@ public:
QSet<QString> expandedINames() const; QSet<QString> expandedINames() const;
static QStringList watchedExpressions(); static QStringList watchedExpressions();
static QHash<QString, int> watcherNames(); static QMap<QString, int> watcherNames();
void appendFormatRequests(DebuggerCommand *cmd); void appendFormatRequests(DebuggerCommand *cmd);
void appendWatchersAndTooltipRequests(DebuggerCommand *cmd); void appendWatchersAndTooltipRequests(DebuggerCommand *cmd);