Debugger: Fix using the same watcher number twice.

Counting the watcher number in a global scope, so they don't get
reinitialized incorrectly with a new engine.

Change-Id: Ifd9efb320e2c0f20b2e2845348a98961f72bf28c
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
David Schulz
2015-03-16 09:10:36 +01:00
committed by hjk
parent 9f545843d3
commit 467c441c93
2 changed files with 5 additions and 7 deletions

View File

@@ -69,6 +69,7 @@ enum { debugModel = 0 };
#define MODEL_DEBUG(s) do { if (debugModel) qDebug() << s; } while (0)
static QHash<QByteArray, int> theWatcherNames;
static int theWatcherCount = 0;
static QHash<QByteArray, int> theTypeFormats;
static QHash<QByteArray, int> theIndividualFormats;
static int theUnprintableBase = -1;
@@ -861,7 +862,7 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role
theWatcherNames.remove(item->d.exp);
item->d.exp = exp;
item->d.name = QString::fromLatin1(exp);
theWatcherNames[exp] = m_handler->m_watcherCounter++;
theWatcherNames[exp] = theWatcherCount++;
m_handler->saveWatchers();
if (engine()->state() == DebuggerNotReady) {
item->d.setAllUnneeded();
@@ -1154,7 +1155,6 @@ void WatchModel::setCurrentItem(const QByteArray &iname)
WatchHandler::WatchHandler(DebuggerEngine *engine)
{
m_engine = engine;
m_watcherCounter = sessionValue("Watchers").toStringList().count();
m_model = new WatchModel(this);
m_contentsValid = false;
m_contentsValid = true; // FIXME
@@ -1318,7 +1318,7 @@ void WatchHandler::watchExpression(const QString &exp0, const QString &name)
WatchData data;
data.exp = exp.toLatin1();
data.name = name.isEmpty() ? exp : name;
theWatcherNames[data.exp] = m_watcherCounter++;
theWatcherNames[data.exp] = theWatcherCount++;
saveWatchers();
if (exp.isEmpty())
@@ -1443,7 +1443,7 @@ void WatchHandler::clearWatches()
m_model->m_watchRoot->removeChildren();
theWatcherNames.clear();
m_watcherCounter = 0;
theWatcherCount = 0;
updateWatchersWindow();
saveWatchers();
}
@@ -1539,7 +1539,7 @@ void WatchHandler::loadSessionData()
{
loadFormats();
theWatcherNames.clear();
m_watcherCounter = 0;
theWatcherCount = 0;
QVariant value = sessionValue("Watchers");
m_model->m_watchRoot->removeChildren();
foreach (const QString &exp, value.toStringList())