diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 4eca5a194807d85fdb3413a38d7e58f6a7c0bf26..0dbe634618be37755eafe90d6b4e85a62d7e4cc4 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -72,8 +72,11 @@ enum { debugModel = 0 }; #define MODEL_DEBUG(s) do { if (debugModel) qDebug() << s; } while (0) #define MODEL_DEBUGX(s) qDebug() << s -QHash<QByteArray, int> WatchHandler::m_watcherNames; -QHash<QByteArray, int> WatchHandler::m_typeFormats; +static QHash<QByteArray, int> theWatcherNames; +static QHash<QByteArray, int> theTypeFormats; +static QHash<QByteArray, int> theIndividualFormats; +static int theUnprintableBase = -1; + static QByteArray stripForFormat(const QByteArray &ba) { @@ -97,17 +100,15 @@ static QByteArray stripForFormat(const QByteArray &ba) return res; } -static int m_unprintableBase = -1; - void WatchHandler::setUnprintableBase(int base) { - m_unprintableBase = base; + theUnprintableBase = base; emitAllChanged(); } int WatchHandler::unprintableBase() { - return m_unprintableBase; + return theUnprintableBase; } //////////////////////////////////////////////////////////////////// @@ -706,10 +707,10 @@ static QString truncateValue(QString v) int WatchModel::itemFormat(const WatchData &data) const { - const int individualFormat = m_handler->m_individualFormats.value(data.iname, -1); + const int individualFormat = theIndividualFormats.value(data.iname, -1); if (individualFormat != -1) return individualFormat; - return m_handler->m_typeFormats.value(stripForFormat(data.type), -1); + return theTypeFormats.value(stripForFormat(data.type), -1); } static inline QString expression(const WatchItem *item) @@ -837,10 +838,10 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const return QString::fromLatin1(data.type); case LocalsTypeFormatRole: - return m_handler->m_typeFormats.value(stripForFormat(data.type), -1); + return theTypeFormats.value(stripForFormat(data.type), -1); case LocalsIndividualFormatRole: - return m_handler->m_individualFormats.value(data.iname, -1); + return theIndividualFormats.value(data.iname, -1); case LocalsRawValueRole: return data.value; @@ -911,9 +912,9 @@ bool WatchModel::setData(const QModelIndex &index, const QVariant &value, int ro case LocalsIndividualFormatRole: { const int format = value.toInt(); if (format == -1) { - m_handler->m_individualFormats.remove(data.iname); + theIndividualFormats.remove(data.iname); } else { - m_handler->m_individualFormats[data.iname] = format; + theIndividualFormats[data.iname] = format; } engine()->updateWatchData(data); break; @@ -1249,9 +1250,9 @@ QDebug operator<<(QDebug d, const WatchModel &m) void WatchModel::formatRequests(QByteArray *out, const WatchItem *item) const { - int format = m_handler->m_individualFormats.value(item->iname, -1); + int format = theIndividualFormats.value(item->iname, -1); if (format == -1) - format = m_handler->m_typeFormats.value(stripForFormat(item->type), -1); + format = theTypeFormats.value(stripForFormat(item->type), -1); if (format != -1) *out += item->iname + ":format=" + QByteArray::number(format) + ','; foreach (const WatchItem *child, item->children) @@ -1311,7 +1312,7 @@ void WatchHandler::endCycle() void WatchHandler::cleanup() { m_expandedINames.clear(); - m_watcherNames.remove(QByteArray()); + theWatcherNames.remove(QByteArray()); m_return->reinitialize(); m_locals->reinitialize(); m_tooltips->reinitialize(); @@ -1429,21 +1430,21 @@ void WatchHandler::removeData(const QByteArray &iname) QByteArray WatchHandler::watcherName(const QByteArray &exp) { - return "watch." + QByteArray::number(m_watcherNames[exp]); + return "watch." + QByteArray::number(theWatcherNames[exp]); } void WatchHandler::watchExpression(const QString &exp) { QTC_ASSERT(m_engine, return); // Do not insert the same entry more then once. - if (m_watcherNames.value(exp.toLatin1())) + if (theWatcherNames.value(exp.toLatin1())) return; // FIXME: 'exp' can contain illegal characters WatchData data; data.exp = exp.toLatin1(); data.name = exp; - m_watcherNames[data.exp] = m_watcherCounter++; + theWatcherNames[data.exp] = m_watcherCounter++; saveWatchers(); if (exp.isEmpty()) @@ -1560,12 +1561,12 @@ void WatchHandler::showEditValue(const WatchData &data) void WatchHandler::clearWatches() { - if (m_watcherNames.isEmpty()) + if (theWatcherNames.isEmpty()) return; const QList<WatchItem *> watches = m_watchers->rootItem()->children; for (int i = watches.size() - 1; i >= 0; i--) m_watchers->destroyItem(watches.at(i)); - m_watcherNames.clear(); + theWatcherNames.clear(); m_watcherCounter = 0; updateWatchersWindow(); emitAllChanged(); @@ -1576,7 +1577,7 @@ void WatchHandler::removeWatchExpression(const QString &exp0) { QByteArray exp = exp0.toLatin1(); MODEL_DEBUG("REMOVE WATCH: " << exp); - m_watcherNames.remove(exp); + theWatcherNames.remove(exp); foreach (WatchItem *item, m_watchers->rootItem()->children) { if (item->exp == exp) { m_watchers->destroyItem(item); @@ -1598,7 +1599,7 @@ QStringList WatchHandler::watchedExpressions() { // Filter out invalid watchers. QStringList watcherNames; - QHashIterator<QByteArray, int> it(m_watcherNames); + QHashIterator<QByteArray, int> it(theWatcherNames); while (it.hasNext()) { it.next(); const QByteArray &watcherName = it.key(); @@ -1621,14 +1622,14 @@ void WatchHandler::loadTypeFormats() while (it.hasNext()) { it.next(); if (!it.key().isEmpty()) - m_typeFormats.insert(it.key().toUtf8(), it.value().toInt()); + theTypeFormats.insert(it.key().toUtf8(), it.value().toInt()); } } void WatchHandler::saveTypeFormats() { QMap<QString, QVariant> typeFormats; - QHashIterator<QByteArray, int> it(m_typeFormats); + QHashIterator<QByteArray, int> it(theTypeFormats); while (it.hasNext()) { it.next(); const int format = it.value(); @@ -1651,7 +1652,7 @@ void WatchHandler::saveSessionData() void WatchHandler::loadSessionData() { loadTypeFormats(); - m_watcherNames.clear(); + theWatcherNames.clear(); m_watcherCounter = 0; QVariant value = debuggerCore()->sessionValue(QLatin1String("Watchers")); foreach (WatchItem *item, m_watchers->rootItem()->children) @@ -1667,7 +1668,7 @@ void WatchHandler::updateWatchers() foreach (WatchItem *item, m_watchers->rootItem()->children) m_watchers->destroyItem(item); // Copy over all watchers and mark all watchers as incomplete. - foreach (const QByteArray &exp, m_watcherNames.keys()) { + foreach (const QByteArray &exp, theWatcherNames.keys()) { WatchData data; data.iname = watcherName(exp); data.setAllNeeded(); @@ -1737,9 +1738,9 @@ void WatchHandler::setFormat(const QByteArray &type0, int format) { const QByteArray type = stripForFormat(type0); if (format == -1) - m_typeFormats.remove(type); + theTypeFormats.remove(type); else - m_typeFormats[type] = format; + theTypeFormats[type] = format; saveTypeFormats(); m_return->emitDataChanged(1); m_locals->emitDataChanged(1); @@ -1751,9 +1752,9 @@ int WatchHandler::format(const QByteArray &iname) const { int result = -1; if (const WatchData *item = findItem(iname)) { - int result = m_individualFormats.value(item->iname, -1); + int result = theIndividualFormats.value(item->iname, -1); if (result == -1) - result = m_typeFormats.value(stripForFormat(item->type), -1); + result = theTypeFormats.value(stripForFormat(item->type), -1); } return result; } @@ -1778,8 +1779,8 @@ QByteArray WatchHandler::expansionRequests() const QByteArray WatchHandler::typeFormatRequests() const { QByteArray ba; - if (!m_typeFormats.isEmpty()) { - QHashIterator<QByteArray, int> it(m_typeFormats); + if (!theTypeFormats.isEmpty()) { + QHashIterator<QByteArray, int> it(theTypeFormats); while (it.hasNext()) { it.next(); ba.append(it.key().toHex()); @@ -1795,8 +1796,8 @@ QByteArray WatchHandler::typeFormatRequests() const QByteArray WatchHandler::individualFormatRequests() const { QByteArray ba; - if (!m_individualFormats.isEmpty()) { - QHashIterator<QByteArray, int> it(m_individualFormats); + if (!theIndividualFormats.isEmpty()) { + QHashIterator<QByteArray, int> it(theIndividualFormats); while (it.hasNext()) { it.next(); ba.append(it.key()); @@ -1911,5 +1912,10 @@ bool WatchHandler::isValidToolTip(const QByteArray &iname) const return item && !item->type.trimmed().isEmpty(); } +QHash<QByteArray, int> WatchHandler::watcherNames() +{ + return theWatcherNames; +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 5af4b463a4c89c5dc3c5fd13b80a3dc37a00e42a..e7ac34b3626773cdc31f87750883b1b20970a920 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -179,8 +179,7 @@ public: QSet<QByteArray> expandedINames() const { return m_expandedINames; } static QStringList watchedExpressions(); - static QHash<QByteArray, int> watcherNames() - { return m_watcherNames; } + static QHash<QByteArray, int> watcherNames(); QByteArray expansionRequests() const; QByteArray typeFormatRequests() const; @@ -222,9 +221,6 @@ private: typedef QMap<QByteArray, QPointer<QObject> > EditHandlers; EditHandlers m_editHandlers; - static QHash<QByteArray, int> m_watcherNames; - static QHash<QByteArray, int> m_typeFormats; - QHash<QByteArray, int> m_individualFormats; // Indexed by iname. TypeFormats m_reportedTypeFormats; // Items expanded in the Locals & Watchers view.