aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2024-02-13 13:46:49 +0100
committerhjk <hjk@qt.io>2024-02-13 17:00:23 +0000
commit02d930b210686b6e33e197cce3d4cdd092073afa (patch)
treedb51d7c8066ec13e41eea69659689adcb0070d38
parentfc9863c768f17454c1cde2fd0395a70eb59342ad (diff)
Debugger: Improve display of elided string data
This was not adding the length before. The problem that the size is suddenly off by a factor of two for QString as elision counts bytes is still present. Change-Id: Ibcb595dc2d9aaa73b3feec955b4d14613307797f Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r--src/plugins/debugger/watchhandler.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index eef0ba5a3b..651c86bf2d 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -818,14 +818,24 @@ static QString formattedValue(const WatchItem *item)
return reformatInteger(integer, format, item->size, false);
}
- if (item->elided) {
- QString v = item->value;
- v.chop(1);
- QString len = item->elided > 0 ? QString::number(item->elided) : "unknown length";
- return quoteUnprintable(v) + "\"... (" + len + ')';
+ const int maxLength = settings().displayStringLimit();
+ QString v = quoteUnprintable(item->value);
+
+ if (v.endsWith('"')) {
+ if (item->elided) {
+ v.chop(1);
+ v.append("...\"");
+ }
+ int len = item->elided ? item->elided : item->value.length() - 2;
+ v += QString(" (%1)").arg(len > 0 ? QString::number(len) : "unknown length");
+ return v;
}
- return quoteUnprintable(item->value);
+ if (v.size() > maxLength) {
+ v.truncate(maxLength);
+ v += QLatin1String("...");
+ }
+ return v;
}
// Get a pointer address from pointer values reported by the debugger.
@@ -886,18 +896,6 @@ QVariant WatchItem::editValue() const
return QVariant(quoteUnprintable(stringValue));
}
-// Truncate value for item view, maintaining quotes.
-static QString truncateValue(QString v)
-{
- enum { maxLength = 512 };
- if (v.size() < maxLength)
- return v;
- const bool isQuoted = v.endsWith('"'); // check for 'char* "Hallo"'
- v.truncate(maxLength);
- v += QLatin1String(isQuoted ? "...\"" : "...");
- return v;
-}
-
static QString displayName(const WatchItem *item)
{
QString result;
@@ -939,13 +937,9 @@ static QString displayName(const WatchItem *item)
return result;
}
-
void WatchItem::updateValueCache() const
{
- QString formatted = truncateValue(formattedValue(this));
- if (formatted.endsWith('"'))
- formatted.append(QString(" (%1)").arg(this->value.length() - 2));
- valueCache = formatted;
+ valueCache = formattedValue(this);
valueCache = watchModel(this)->removeNamespaces(valueCache);
if (valueCache.isEmpty() && this->address)
valueCache += QString::fromLatin1("@0x" + QByteArray::number(this->address, 16));