diff options
author | hjk <hjk121@nokiamail.com> | 2013-10-22 16:07:08 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2013-10-22 17:13:16 +0200 |
commit | e643f3bf7400661bebb170e286da6976c8893667 (patch) | |
tree | da4bf082397a535381cece31302cbd8ef4ee5db5 | |
parent | cde0a8828d89817bd6193e4ff12314a726cc46e1 (diff) | |
download | qt-creator-e643f3bf7400661bebb170e286da6976c8893667.tar.gz |
Debugger: Avoid Gui dependency of dumper autotest
Change-Id: Ie51554216ad7b132839c2779c2f647ad6222db5f
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
-rw-r--r-- | src/plugins/debugger/watchdata.cpp | 28 | ||||
-rw-r--r-- | tests/auto/debugger/dumpers.pro | 1 | ||||
-rw-r--r-- | tests/auto/debugger/tst_dumpers.cpp | 2 |
3 files changed, 28 insertions, 3 deletions
diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index 9cbe253d7e..8cad1a3c13 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -34,7 +34,6 @@ #include "watchutils.h" #include "debuggerprotocol.h" -#include <QTextDocument> // Qt::escape() in Qt 4 #include <QDebug> //////////////////////////////////////////////////////////////////// @@ -338,11 +337,36 @@ QString WatchData::toString() const return res + QLatin1Char('}'); } +static QString htmlEscape(const QString &plain) +{ +#if QT_VERSION >= 0x050000 + return Qt::escape(plain); +#else + // Copied from Qt to avoid GUI dependency + // (Qt::escape has been moved in Qt 5) + QString rich; + rich.reserve(int(plain.length() * qreal(1.1))); + for (int i = 0; i < plain.length(); ++i) { + if (plain.at(i) == QLatin1Char('<')) + rich += QLatin1String("<"); + else if (plain.at(i) == QLatin1Char('>')) + rich += QLatin1String(">"); + else if (plain.at(i) == QLatin1Char('&')) + rich += QLatin1String("&"); + else if (plain.at(i) == QLatin1Char('"')) + rich += QLatin1String("""); + else + rich += plain.at(i); + } + return rich; +#endif +} + // Format a tooltip fow with aligned colon. static void formatToolTipRow(QTextStream &str, const QString &category, const QString &value) { - QString val = Qt::escape(value); + QString val = htmlEscape(value); val.replace(QLatin1Char('\n'), QLatin1String("<br>")); str << "<tr><td>" << category << "</td><td> : </td><td>" << val << "</td></tr>"; diff --git a/tests/auto/debugger/dumpers.pro b/tests/auto/debugger/dumpers.pro index 0cba83242f..331ddc1024 100644 --- a/tests/auto/debugger/dumpers.pro +++ b/tests/auto/debugger/dumpers.pro @@ -1,6 +1,7 @@ QTC_LIB_DEPENDS += cplusplus utils QT += network +QT -= gui include(../qttest.pri) diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index 4760aba1d9..959ef948e4 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -4920,7 +4920,7 @@ void tst_Dumpers::dumper_data() int main(int argc, char *argv[]) { - QApplication app(argc, argv); + QCoreApplication app(argc, argv); tst_Dumpers test; return QTest::qExec(&test, argc, argv); } |