From 5f13608c61e0d4f3e38b15a95c1b1e0480062de4 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Thu, 26 Aug 2010 13:20:14 +0200
Subject: [PATCH] debugger: replace \n by \\n in locals & watchers

http://bugreports.qt.nokia.com/browse/QTCREATORBUG-2144
---
 src/plugins/debugger/watchhandler.cpp   | 4 +++-
 tests/manual/gdbdebugger/boost/main.cpp | 2 ++
 tests/manual/gdbdebugger/simple/app.cpp | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index 7b952585dcc..6c58fa0f588 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -448,7 +448,9 @@ static inline QString formattedValue(const WatchData &data, int format)
             return reformatInteger(data.value.toULongLong(), format);
         return reformatInteger(data.value.toLongLong(), format);
     }
-    return data.value;
+    QString result = data.value;
+    result.replace(QLatin1Char('\n'), QLatin1String("\\n"));
+    return result;
 }
 
 bool WatchModel::canFetchMore(const QModelIndex &index) const
diff --git a/tests/manual/gdbdebugger/boost/main.cpp b/tests/manual/gdbdebugger/boost/main.cpp
index ada9697e32b..8aafda0e8a0 100644
--- a/tests/manual/gdbdebugger/boost/main.cpp
+++ b/tests/manual/gdbdebugger/boost/main.cpp
@@ -21,9 +21,11 @@ void testOptional()
     optional<double> d;
     optional<Large> l;
     optional<std::string &> sr;
+    optional<std::string> s;
     std::string as = "hallo";
     i = 1;
     sr = as;
+    s = as;
     l = Large();
     i = 2;
     i = 3;
diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp
index e6286ef922c..13c71bf80a7 100644
--- a/tests/manual/gdbdebugger/simple/app.cpp
+++ b/tests/manual/gdbdebugger/simple/app.cpp
@@ -1939,7 +1939,7 @@ int main(int argc, char *argv[])
     testQHash1();
     testSignalSlot(argc, argv);
 
-    QString hallo = "hallo";
+    QString hallo = "hallo\nwelt";
     QStringList list;
     list << "aaa" << "bbb" << "cc";
 
-- 
GitLab