From 3ba72d0e1e8e9a3bd3cfa645be0b43ab95dbd4ae Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Wed, 20 May 2009 16:59:40 +0200
Subject: [PATCH] Stabilized the QString debug dumper a bit on Windows.

Try to prevent dumper crashes on
unitialized variables that slow down the debugger.
Acked-by: hjk <qtc-committer@nokia.com>
---
 share/qtcreator/gdbmacros/gdbmacros.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp
index 1778edad463..c6051526c67 100644
--- a/share/qtcreator/gdbmacros/gdbmacros.cpp
+++ b/share/qtcreator/gdbmacros/gdbmacros.cpp
@@ -1995,10 +1995,15 @@ static void qDumpQString(QDumper &d)
 {
     const QString &str = *reinterpret_cast<const QString *>(d.data);
 
-    if (!str.isEmpty()) {
-        qCheckAccess(str.unicode());
-        if (!str.unicode()[str.size()].isNull()) // must be '\0' terminated
-            qCheckAccess(0);
+    const int size = str.size();
+    if (size < 0)
+        return;
+    if (size) {
+        const QChar *unicode = str.unicode();
+        qCheckAccess(unicode);
+        qCheckAccess(unicode + size);
+        if (!unicode[size].isNull()) // must be '\0' terminated
+            return;
     }
 
     P(d, "value", str);
-- 
GitLab