diff options
author | hjk <hjk121@nokiamail.com> | 2013-10-13 22:29:22 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2013-10-21 14:05:22 +0200 |
commit | 11bf2676045e6b74cfde3f321e628893eb939e0c (patch) | |
tree | 09836a182b19104e232371361050bff1a2c23386 /src/plugins | |
parent | e11f9e55b57683876097de8e180465becb8f91e8 (diff) | |
download | qt-creator-11bf2676045e6b74cfde3f321e628893eb939e0c.tar.gz |
Debugger: Offer base changes for all integral looking values.
If it talks like a duck, and walks like a duck...
Change-Id: I166a452a9d067285467b346a4ef5d4de646d3a31
Reviewed-by: hjk <hjk121@nokiamail.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/debugger/watchhandler.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index bd40997ce8..afff80085b 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -508,6 +508,25 @@ static int formatToIntegerBase(int format) return 10; } +static bool isIntegralValue(const QString &value) +{ + if (value.startsWith(QLatin1Char('-'))) + return isIntegralValue(value.mid(1)); + + bool ok; + value.toULongLong(&ok, 10); + if (ok) + return true; + value.toULongLong(&ok, 16); + if (ok) + return true; + value.toULongLong(&ok, 8); + if (ok) + return true; + + return false; +} + template <class IntType> QString reformatInteger(IntType value, int format) { switch (format) { @@ -527,7 +546,7 @@ static QString reformatCharacter(int code, int format) const QString codeS = reformatInteger(code, format); if (code < 0) // Append unsigned value. return codeS + QLatin1String(" / ") + reformatInteger(256 + code, format); - const QChar c = QLatin1Char(code); + const QChar c = QChar(uint(code)); if (c.isPrint()) return codeS + QLatin1String(" '") + c + QLatin1Char('\''); switch (code) { @@ -623,14 +642,7 @@ QString WatchModel::formattedValue(const WatchData &data) const return value; } - if (isIntType(data.type)) { - if (value.isEmpty()) - return value; - // Do not reformat booleans (reported as 'true, false'). - const QChar firstChar = value.at(0); - if (!firstChar.isDigit() && firstChar != QLatin1Char('-')) - return value; - + if (isIntegralValue(value)) { // Append quoted, printable character also for decimal. const int format = itemFormat(data); if (data.type.endsWith("char")) { @@ -1225,9 +1237,7 @@ QStringList WatchModel::typeFormatList(const WatchData &data) const << tr("Latin1 string") << tr("UTF8 string") << tr("Local 8bit string"); - bool ok = false; - (void)data.value.toULongLong(&ok, 0); - if ((isIntType(data.type) && data.type != "bool") || ok) + if (isIntegralValue(data.value)) return QStringList() << tr("Decimal") << tr("Hexadecimal") |