From 4cd90ff022f814011c5550c59c9928cdda5a6ba4 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Fri, 5 Mar 2010 12:50:43 +0100
Subject: [PATCH] debugger: fix qvariant dumper for custom types

---
 share/qtcreator/gdbmacros/gdbmacros.py | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/share/qtcreator/gdbmacros/gdbmacros.py b/share/qtcreator/gdbmacros/gdbmacros.py
index 0bcb16e8c3f..0c5ccac0179 100644
--- a/share/qtcreator/gdbmacros/gdbmacros.py
+++ b/share/qtcreator/gdbmacros/gdbmacros.py
@@ -1603,14 +1603,9 @@ def qdump__QVariant(d, item):
         inner = d.ns + "QVector4D"
     elif variantType == 86: # QVariant::Quadernion
         inner = d.ns + "QQuadernion"
-    else:
-        # FIXME: handle User types
-        d.putValue("(unknown type %d)" % variantType)
-        # typeName = QMetaType::typeName(typ)
-        # exp =  "'qVariantValue<%s >'(*('"NS"QVariant'*)%p)"
-        d.putNumChild(0)
 
     if len(inner):
+        # Build-in types.
         if len(innert) == 0:
             innert = inner
         d.putValue("(%s)" % innert)
@@ -1625,6 +1620,21 @@ def qdump__QVariant(d, item):
             d.putItemHelper(Item(val, item.iname, "data", "data"))
             d.endHash()
             d.endChildren()
+    else:
+        # User types.
+        func = "typeToName(('%sQVariant::Type')%d)" % (d.ns, variantType)
+        type = str(call(item.value, func))
+        type = type[type.find('"') + 1 : type.rfind('"')]
+        type = type.replace("Q", d.ns + "Q") # HACK!
+        data = call(item.value, "constData()")
+        tdata = data.cast(gdb.lookup_type(type).pointer()).dereference()
+        d.putValue("(%s)" % tdata.type)
+        d.putType(tdata.type)
+        d.putNumChild(1)
+        if d.isExpanded(item):
+            d.beginChildren()
+            d.putItem(Item(tdata, item.iname, "data", "data"))
+            d.endChildren()
 
 
 def qdump__QVector(d, item):
-- 
GitLab