summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2013-10-22 16:07:08 +0200
committerhjk <hjk121@nokiamail.com>2013-10-22 17:13:16 +0200
commite643f3bf7400661bebb170e286da6976c8893667 (patch)
treeda4bf082397a535381cece31302cbd8ef4ee5db5
parentcde0a8828d89817bd6193e4ff12314a726cc46e1 (diff)
downloadqt-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.cpp28
-rw-r--r--tests/auto/debugger/dumpers.pro1
-rw-r--r--tests/auto/debugger/tst_dumpers.cpp2
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("&lt;");
+ else if (plain.at(i) == QLatin1Char('>'))
+ rich += QLatin1String("&gt;");
+ else if (plain.at(i) == QLatin1Char('&'))
+ rich += QLatin1String("&amp;");
+ else if (plain.at(i) == QLatin1Char('"'))
+ rich += QLatin1String("&quot;");
+ 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);
}