Commit f9eea7e1 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger: Fix broken display of containers with truncated item count.

Introduce convention '<>10 items>' meaning <more than 10 items>.

Task-number: QTCREATORBUG-3132
parent 1c18090b
......@@ -490,8 +490,10 @@ struct QDumper
void beginItem(const char *name); // start of named item, ready to accept value
void endItem(); // end of named item, used after value output is complete
// convienience for putting "<n items>"
// convenience for putting "<n items>"
void putItemCount(const char *name, int count);
// convenience for putting "<>n items>" (more than X items)
void putTruncatedItemCount(const char *name, int count);
void putCommaIfNeeded();
// convienience function for writing the last item of an abbreviated list
void putEllipsis();
......@@ -753,6 +755,11 @@ void QDumper::putItemCount(const char *name, int count)
put(name).put("=\"<").put(count).put(" items>\"");
}
void QDumper::putTruncatedItemCount(const char *name, int count)
{
putCommaIfNeeded();
put(name).put("=\"<>").put(count).put(" items>\"");
}
//
// Some helpers to keep the dumper code short
......@@ -3148,16 +3155,18 @@ static void qDumpStdList(QDumper &d)
p = deref(addOffset(p, sizeof(void*)));
qCheckAccess(p);
#endif
int nn = 0;
std::list<int>::size_type nn = 0;
const std::list<int>::size_type maxItems = 100;
std::list<int>::const_iterator it = list.begin();
const std::list<int>::const_iterator cend = list.end();
for (; nn < 101 && it != cend; ++nn, ++it)
for (; nn < maxItems && it != cend; ++nn, ++it)
qCheckAccess(it.operator->());
if (nn > 100)
d.putItem("value", "<more than 100 items>");
else
if (it != cend) {
d.putTruncatedItemCount("value", nn);
} else {
d.putItemCount("value", nn);
}
d.putItem("numchild", nn);
d.putItem("valueeditable", "false");
......@@ -3167,7 +3176,7 @@ static void qDumpStdList(QDumper &d)
isPointerType(d.innerType) ? strippedInnerType.data() : 0;
d.beginChildren(d.innerType);
it = list.begin();
for (int i = 0; i < 1000 && it != cend; ++i, ++it) {
for (std::list<int>::size_type i = 0; i < maxItems && it != cend; ++i, ++it) {
d.beginHash();
qDumpInnerValueOrPointer(d, d.innerType, stripped, it.operator->());
d.endHash();
......@@ -3250,7 +3259,6 @@ static void qDumpStdMapHelper(QDumper &d)
for (int i = 0; i < nn && i < 10 && it != cend; ++i, ++it)
qCheckAccess(it.operator->());
const QByteArray strippedInnerType = stripPointerType(d.innerType);
d.putItem("numchild", nn);
d.putItemCount("value", nn);
d.putItem("valueeditable", "false");
......@@ -3399,7 +3407,7 @@ static void qDumpStdSet(QDumper &d)
#ifdef Q_CC_MSVC
// As the set implementation inherits from a base class
// depending on the key, use something equivalent to iterate it.
const int innerSize = d.extraInt[0];
const size_t innerSize = d.extraInt[0];
if (innerSize == sizeof(int)) {
qDumpStdSetHelper<int>(d);
return;
......
......@@ -481,8 +481,15 @@ static inline QString formattedValue(const WatchData &data, int format)
else if (result == QLatin1String("<not accessible>"))
result = WatchHandler::tr("<not accessible>");
else if (result.endsWith(" items>")) {
const int size = result.mid(1, result.indexOf(' ') - 1).toInt();
result = WatchHandler::tr("<%n items>", 0, size);
// '<10 items>' or '<>10 items>' (more than)
bool ok;
const bool moreThan = result.at(1) == QLatin1Char('>');
const int numberPos = moreThan ? 2 : 1;
const int size = result.mid(numberPos, result.indexOf(' ') - numberPos).toInt(&ok);
QTC_ASSERT(ok, qWarning("WatchHandler: Invalid item count '%s'", qPrintable(result)) ; )
result = moreThan ?
WatchHandler::tr("<more than %n items>", 0, size) :
WatchHandler::tr("<%n items>", 0, size);
}
}
return result;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment