From 33d9772e5f1098950cece15e90481ac9652e88d8 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Mon, 18 Jul 2011 15:41:56 +0200
Subject: [PATCH] Debugger: Remove enclosing quotes when editing strings in
 watchwindow.

When doubleclicking to edit a string value displayed as '0x3443 "foo"'
in the watchwindow, the whole display value including quotes
was set to the line edit. Remove them.

Change-Id: I0327e3e0fa2270047c8c1b28b07ad5bc5e531644
Reviewed-on: http://codereview.qt.nokia.com/1771
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
---
 src/plugins/debugger/watchhandler.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index 02c1152e0d0..f4895317890 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -452,9 +452,17 @@ static inline QVariant editValue(const WatchData &d)
     default:
         break;
     }
-    // Replace newlines, which will cause line edit troubles.
+    // Some string value: '0x434 "Hallo"':
+    // Remove quotes and replace newlines, which will cause line edit troubles.
     QString stringValue = d.value;
-    stringValue.replace(QLatin1String("\n"), QLatin1String("\\n"));
+    if (stringValue.endsWith(QLatin1Char('"'))) {
+        const int leadingDoubleQuote = stringValue.indexOf(QLatin1Char('"'));
+        if (leadingDoubleQuote != stringValue.size() - 1) {
+            stringValue.truncate(stringValue.size() - 1);
+            stringValue.remove(0, leadingDoubleQuote + 1);
+            stringValue.replace(QLatin1String("\n"), QLatin1String("\\n"));
+        }
+    }
     return QVariant(stringValue);
 }
 
-- 
GitLab