Commit 8c02d6e0 authored by hjk's avatar hjk

Debugger: Fix QChar dumper with Python 3

Change-Id: I7da412c9bdaf3a8f65484ac99f06fc31a5cdc1c3
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 59fd03ab
......@@ -70,20 +70,8 @@ def qdump__QByteArray(d, value):
d.putArrayData(d.charType(), data, size)
def str2Utf8hex2(s):
# Returns UTF-8 hex-data of string suitable for QByteArray::fromHex()
ret = []
for c in s.encode('utf-8'):
ret.append('%02x' % ord(c))
return ''.join(ret)
def qdump__QChar(d, value):
ucs = int(value["ucs"])
if ucs < 32:
ch = '?'
else:
ch = unichr(ucs)
d.putValue(str2Utf8hex2(u"'%s' (%d)" % (ch, ucs)), Hex2EncodedUtf8WithoutQuotes)
d.putValue(int(value["ucs"]))
d.putNumChild(0)
......
......@@ -645,7 +645,7 @@ QString WatchModel::formattedValue(const WatchData &data) const
if (isIntegralValue(value)) {
// Append quoted, printable character also for decimal.
const int format = itemFormat(data);
if (data.type.endsWith("char")) {
if (data.type.endsWith("char") || data.type.endsWith("QChar")) {
bool ok;
const int code = value.toInt(&ok);
return ok ? reformatCharacter(code, format) : value;
......
......@@ -1163,6 +1163,14 @@ void tst_Dumpers::dumper_data()
% Check("ba1", "\"Hell\"", "@QByteArray")
% Check("ba2", "\"ello\"", "@QByteArray");
QTest::newRow("QChar")
<< Data("#include <QString>\n",
"QString s = QLatin1String(\"x\");\n"
"QChar c = s.at(0);\n"
"unused(&c);\n")
% CoreProfile()
% Check("c", "120", "@QChar");
QTest::newRow("QDate0")
<< Data("#include <QDate>\n",
"QDate date;\n"
......@@ -1653,8 +1661,8 @@ void tst_Dumpers::dumper_data()
% CoreProfile()
% Check("l0", "<0 items>", "@QList<@QChar>")
% Check("l", "<3 items>", "@QList<@QChar>")
% Check("l.0", "[0]", "'a' (97)", "@QChar")
% Check("l.2", "[2]", "'c' (99)", "@QChar");
% Check("l.0", "[0]", "97", "@QChar")
% Check("l.2", "[2]", "99", "@QChar");
QTest::newRow("QListQULongLong")
<< Data("#include <QList>\n",
......@@ -3370,7 +3378,7 @@ void tst_Dumpers::dumper_data()
% Check("var4", "4", "@QVariant (qlonglong)")
% Check("var5", "5", "@QVariant (qulonglong)")
% Check("var6", "6.0", "@QVariant (double)")
% Check("var7", "'?' (7)", "@QVariant (QChar)")
% Check("var7", "7", "@QVariant (QChar)")
% Check("var10", "\"Hello 10\"", "@QVariant (QString)")
% Check("var11", "<2 items>", "@QVariant (QStringList)")
% Check("var11.1", "[1]", "\"World\"", "@QString")
......
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