diff options
author | hjk <[email protected]> | 2011-11-30 11:09:10 +0100 |
---|---|---|
committer | hjk <[email protected]> | 2011-11-30 16:04:24 +0100 |
commit | 844437c666ece31b76f3f482e06c59aa4419987e (patch) | |
tree | 222a6a62230edfc0429a2c688f33771aaa030054 /src/plugins/debugger/watchhandler.cpp | |
parent | 27211de08356cc0f99ccfc1488a64a911acacf84 (diff) |
debugger: use the same type formats for arrays of same base type
Task-number: QTCREATORBUG-5582
Change-Id: I690c755fc5d2ea127ea12f65f799accb10ff20c9
Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins/debugger/watchhandler.cpp')
-rw-r--r-- | src/plugins/debugger/watchhandler.cpp | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 5ff800585bc..1264f95f013 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -75,13 +75,28 @@ enum { debugModel = 0 }; QHash<QByteArray, int> WatchHandler::m_watcherNames; QHash<QByteArray, int> WatchHandler::m_typeFormats; -static QByteArray stripTemplate(const QByteArray &ba) -{ - int pos = ba.indexOf('<'); - return pos == -1 ? ba : ba.left(pos); +static QByteArray stripForFormat(const QByteArray &ba) +{ + QByteArray res; + res.reserve(ba.size()); + int inArray = 0; + for (int i = 0; i != ba.size(); ++i) { + const char c = ba.at(i); + if (c == '<') + break; + if (c == '[') + ++inArray; + if (c == ']') + --inArray; + if (c == ' ') + continue; + if (inArray && c >= '0' && c <= '9') + continue; + res.append(c); + } + return res; } - static int m_unprintableBase = -1; void WatchHandler::setUnprintableBase(int base) @@ -672,7 +687,7 @@ int WatchModel::itemFormat(const WatchData &data) const const int individualFormat = m_handler->m_individualFormats.value(data.iname, -1); if (individualFormat != -1) return individualFormat; - return m_handler->m_typeFormats.value(stripTemplate(data.type), -1); + return m_handler->m_typeFormats.value(stripForFormat(data.type), -1); } static inline QString expression(const WatchItem *item) @@ -800,7 +815,7 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const return QString::fromLatin1(data.type); case LocalsTypeFormatRole: - return m_handler->m_typeFormats.value(stripTemplate(data.type), -1); + return m_handler->m_typeFormats.value(stripForFormat(data.type), -1); case LocalsIndividualFormatRole: return m_handler->m_individualFormats.value(data.iname, -1); @@ -961,7 +976,7 @@ QStringList WatchHandler::typeFormatList(const WatchData &data) const << tr("Binary") << tr("Octal"); // Hack: Compensate for namespaces. - QString type = stripTemplate(data.type); + QString type = stripForFormat(data.type); int pos = type.indexOf("::Q"); if (pos >= 0 && type.count(':') == 2) type = type.mid(pos + 2); @@ -1210,7 +1225,7 @@ void WatchModel::formatRequests(QByteArray *out, const WatchItem *item) const { int format = m_handler->m_individualFormats.value(item->iname, -1); if (format == -1) - format = m_handler->m_typeFormats.value(stripTemplate(item->type), -1); + format = m_handler->m_typeFormats.value(stripForFormat(item->type), -1); if (format != -1) *out += item->iname + ":format=" + QByteArray::number(format) + ','; foreach (const WatchItem *child, item->children) @@ -1686,7 +1701,7 @@ QModelIndex WatchHandler::itemIndex(const QByteArray &iname) const void WatchHandler::setFormat(const QByteArray &type0, int format) { - const QByteArray type = stripTemplate(type0); + const QByteArray type = stripForFormat(type0); if (format == -1) m_typeFormats.remove(type); else @@ -1704,7 +1719,7 @@ int WatchHandler::format(const QByteArray &iname) const if (const WatchData *item = findItem(iname)) { int result = m_individualFormats.value(item->iname, -1); if (result == -1) - result = m_typeFormats.value(stripTemplate(item->type), -1); + result = m_typeFormats.value(stripForFormat(item->type), -1); } return result; } @@ -1762,7 +1777,7 @@ QByteArray WatchHandler::individualFormatRequests() const void WatchHandler::addTypeFormats(const QByteArray &type, const QStringList &formats) { - m_reportedTypeFormats.insert(stripTemplate(type), formats); + m_reportedTypeFormats.insert(stripForFormat(type), formats); } QString WatchHandler::editorContents() |