diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index 9cbe253d7e4..8cad1a3c13c 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -34,7 +34,6 @@ #include "watchutils.h" #include "debuggerprotocol.h" -#include // Qt::escape() in Qt 4 #include //////////////////////////////////////////////////////////////////// @@ -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("
")); str << "" << category << " : " << val << ""; diff --git a/tests/auto/debugger/dumpers.pro b/tests/auto/debugger/dumpers.pro index 0cba83242fd..331ddc10243 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 4760aba1d97..959ef948e4f 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); }