diff --git a/share/qtcreator/gdbmacros/gdbmacros.py b/share/qtcreator/gdbmacros/gdbmacros.py
index 63b7c17c1426e3ccc05ad9712ec301d5f6b2cc18..49bf406420ad0ab2b8f0ab5e2ab67bf3d17ee6fa 100644
--- a/share/qtcreator/gdbmacros/gdbmacros.py
+++ b/share/qtcreator/gdbmacros/gdbmacros.py
@@ -1660,14 +1660,19 @@ def qdump__QTextCodec(d, item):
 
 
 def qdump__QTextCursor(d, item):
-    p = item.value["d"]["d"].dereference()
-    d.putValue(p["position"])
-    d.putNumChild(1)
-    if d.isExpanded(item):
-        with Children(d):
-            d.putIntItem("position", p["position"])
-            d.putIntItem("anchor", p["anchor"])
-            d.putCallItem("selected", item, "selectedText()")
+    dd = item.value["d"]["d"]
+    if isNull(dd):
+        d.putValue("(invalid)")
+        d.putNumChild(0)
+    else:
+        p = dd.dereference()
+        d.putValue(p["position"])
+        d.putNumChild(1)
+        if d.isExpanded(item):
+            with Children(d):
+                d.putIntItem("position", p["position"])
+                d.putIntItem("anchor", p["anchor"])
+                d.putCallItem("selected", item, "selectedText()")
 
 
 def qdump__QTextDocument(d, item):