OSDN Git Service

Debugger: Remove enclosing quotes when editing strings in watchwindow.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Mon, 18 Jul 2011 13:41:56 +0000 (15:41 +0200)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>
Tue, 19 Jul 2011 13:20:21 +0000 (15:20 +0200)
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

index 02c1152..f489531 100644 (file)
@@ -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);
 }