diff --git a/src/plugins/debugger/watchdata.h b/src/plugins/debugger/watchdata.h index c25e1962f9c..4ef57eacf18 100644 --- a/src/plugins/debugger/watchdata.h +++ b/src/plugins/debugger/watchdata.h @@ -78,6 +78,9 @@ public: bool outdated = false; // \internal item is to be removed. double time = 0; // Time used on the dumper side to produce this item + mutable QString valueCache; // Pre-computed displayed value + void updateValueCache() const; // implemented in watchhandler.cpp + private: void parseHelper(const GdbMi &input, bool maySort); }; diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index f86bcb1c62e..4823a952b90 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -929,15 +929,22 @@ static QString displayName(const WatchItem *item) return result; } -static QString displayValue(const WatchItem *item) + +void WatchItem::updateValueCache() const { - QString result = truncateValue(formattedValue(item)); - result = watchModel(item)->removeNamespaces(result); - if (result.isEmpty() && item->address) - result += QString::fromLatin1("@0x" + QByteArray::number(item->address, 16)); + valueCache = truncateValue(formattedValue(this)); + valueCache = watchModel(this)->removeNamespaces(valueCache); + if (valueCache.isEmpty() && this->address) + valueCache += QString::fromLatin1("@0x" + QByteArray::number(this->address, 16)); // if (origaddr) // result += QString::fromLatin1(" (0x" + QByteArray::number(origaddr, 16) + ')'); - return result; +} + +static QString displayValue(const WatchItem *item) +{ + if (item->valueCache.isEmpty()) + item->updateValueCache(); + return item->valueCache; } static QString displayType(const WatchItem *item)