forked from qt-creator/qt-creator
Debugger/CDB: Increase limits on string size in watch data.
Introduce truncation in item view instead (full value visible in
ToolTip).
Reviewed-by: hjk
Task-number: QTCREATORBUG-305
(cherry picked from commit 55b4e6d383
)
This commit is contained in:
@@ -750,9 +750,10 @@ static inline bool getUnsignedHexValue(CIDebugSymbolGroup *sg, int index, quint6
|
||||
return getUnsignedHexValue(stringValue, value);
|
||||
}
|
||||
|
||||
enum { maxStringLength = 4096 };
|
||||
|
||||
int CdbSymbolGroupContext::dumpQString(CIDebugDataSpaces *ds, WatchData *wd)
|
||||
{
|
||||
const int maxLength = 40;
|
||||
QString errorMessage;
|
||||
unsigned long stringIndex;
|
||||
if (!lookupPrefix(wd->iname, &stringIndex))
|
||||
@@ -774,9 +775,9 @@ int CdbSymbolGroupContext::dumpQString(CIDebugDataSpaces *ds, WatchData *wd)
|
||||
if (!getUnsignedHexValue(m_symbolGroup, arrayIndex, &array))
|
||||
return 5;
|
||||
// Fetch
|
||||
const bool truncated = size > maxLength;
|
||||
const bool truncated = size > maxStringLength;
|
||||
if (truncated)
|
||||
size = maxLength;
|
||||
size = maxStringLength;
|
||||
const QChar doubleQuote = QLatin1Char('"');
|
||||
QString value;
|
||||
if (size > 0) {
|
||||
@@ -808,7 +809,6 @@ int CdbSymbolGroupContext::dumpQString(CIDebugDataSpaces *ds, WatchData *wd)
|
||||
|
||||
int CdbSymbolGroupContext::dumpStdString(WatchData *wd)
|
||||
{
|
||||
const int maxLength = 40;
|
||||
QString errorMessage;
|
||||
unsigned long stringIndex;
|
||||
if (!lookupPrefix(wd->iname, &stringIndex))
|
||||
@@ -835,8 +835,8 @@ int CdbSymbolGroupContext::dumpStdString(WatchData *wd)
|
||||
if (quotePos == -1)
|
||||
return 1;
|
||||
bufValue.remove(0, quotePos);
|
||||
if (bufValue.size() > maxLength) {
|
||||
bufValue.truncate(maxLength);
|
||||
if (bufValue.size() > maxStringLength) {
|
||||
bufValue.truncate(maxStringLength);
|
||||
bufValue += QLatin1String("...\"");
|
||||
}
|
||||
wd->setValue(bufValue);
|
||||
|
@@ -727,6 +727,18 @@ void WatchModel::emitDataChanged(int column, const QModelIndex &parentIndex)
|
||||
emitDataChanged(column, index(i, 0, parentIndex));
|
||||
}
|
||||
|
||||
// Truncate value for item view, maintaining quotes
|
||||
static inline QString truncateValue(QString v)
|
||||
{
|
||||
enum { maxLength = 512 };
|
||||
if (v.size() < maxLength)
|
||||
return v;
|
||||
const bool isQuoted = v.endsWith(QLatin1Char('"')); // check for 'char* "Hallo"'
|
||||
v.truncate(maxLength);
|
||||
v += isQuoted ? QLatin1String("...\"") : QLatin1String("...");
|
||||
return v;
|
||||
}
|
||||
|
||||
QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
||||
{
|
||||
const WatchItem &data = *watchItem(idx);
|
||||
@@ -735,9 +747,9 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
||||
case Qt::DisplayRole: {
|
||||
switch (idx.column()) {
|
||||
case 0: return data.name;
|
||||
case 1: return formattedValue(data,
|
||||
case 1: return truncateValue(formattedValue(data,
|
||||
m_handler->m_individualFormats.value(data.iname, -1),
|
||||
m_handler->m_typeFormats.value(data.type, -1));
|
||||
m_handler->m_typeFormats.value(data.type, -1)));
|
||||
case 2:
|
||||
if (!data.displayedType.isEmpty())
|
||||
return data.displayedType;
|
||||
|
Reference in New Issue
Block a user