forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -818,14 +818,24 @@ static QString formattedValue(const WatchItem *item)
|
|||||||
return reformatInteger(integer, format, item->size, false);
|
return reformatInteger(integer, format, item->size, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->elided) {
|
const int maxLength = settings().displayStringLimit();
|
||||||
QString v = item->value;
|
QString v = quoteUnprintable(item->value);
|
||||||
v.chop(1);
|
|
||||||
QString len = item->elided > 0 ? QString::number(item->elided) : "unknown length";
|
if (v.endsWith('"')) {
|
||||||
return quoteUnprintable(v) + "\"... (" + len + ')';
|
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.
|
// Get a pointer address from pointer values reported by the debugger.
|
||||||
@@ -886,18 +896,6 @@ QVariant WatchItem::editValue() const
|
|||||||
return QVariant(quoteUnprintable(stringValue));
|
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)
|
static QString displayName(const WatchItem *item)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
@@ -939,13 +937,9 @@ static QString displayName(const WatchItem *item)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WatchItem::updateValueCache() const
|
void WatchItem::updateValueCache() const
|
||||||
{
|
{
|
||||||
QString formatted = truncateValue(formattedValue(this));
|
valueCache = formattedValue(this);
|
||||||
if (formatted.endsWith('"'))
|
|
||||||
formatted.append(QString(" (%1)").arg(this->value.length() - 2));
|
|
||||||
valueCache = formatted;
|
|
||||||
valueCache = watchModel(this)->removeNamespaces(valueCache);
|
valueCache = watchModel(this)->removeNamespaces(valueCache);
|
||||||
if (valueCache.isEmpty() && this->address)
|
if (valueCache.isEmpty() && this->address)
|
||||||
valueCache += QString::fromLatin1("@0x" + QByteArray::number(this->address, 16));
|
valueCache += QString::fromLatin1("@0x" + QByteArray::number(this->address, 16));
|
||||||
|
Reference in New Issue
Block a user