OSDN Git Service

debugger: cache results of finding out the current Qt namespace
authorhjk <qtc-committer@nokia.com>
Mon, 20 Dec 2010 12:54:57 +0000 (13:54 +0100)
committerhjk <qtc-committer@nokia.com>
Mon, 20 Dec 2010 13:47:52 +0000 (14:47 +0100)
share/qtcreator/gdbmacros/dumper.py

index 22e76fe..c1d8879 100644 (file)
@@ -788,8 +788,13 @@ def makeExpression(value):
     #warn("  EXP: %s" % exp)
     return exp
 
+qqNs = None
+
 def qtNamespace():
+    if not qqNs is None:
+        return qqNs
     try:
+        global qqNs
         str = catchCliOutput("ptype QString::Null")[0]
         # The result looks like:
         # "type = const struct myns::QString::Null {"
@@ -797,7 +802,8 @@ def qtNamespace():
         # "}"
         pos1 = str.find("struct") + 7
         pos2 = str.find("QString::Null")
-        return str[pos1:pos2]
+        qqNs = str[pos1:pos2]
+        return qqNs
     except:
         return ""
 
@@ -977,7 +983,6 @@ qqDumpers = {}
 
 # This is a cache of the namespace of the currently used Qt version.
 # FIXME: This is not available on 'bbsetup' time, only at 'bb' time.
-qqNs = ""
 
 # This is a cache of typenames->bool saying whether we are QObject
 # derived.
@@ -1011,10 +1016,11 @@ def bbsetup():
                 pass
             qqFormats[name] = formats
     result = "dumpers=["
-    qqNs = qtNamespace()
+    #qqNs = qtNamespace() # This is too early
     for key, value in qqFormats.items():
         result += '{type="%s",formats="%s"},' % (key, value)
-    result += '],namespace="%s"' % qqNs
+    result += ']'
+    #result += ',namespace="%s"' % qqNs
     result += ',hasInferiorThreadList="%s"' % int(hasInferiorThreadList())
     return result
 
@@ -1120,8 +1126,8 @@ class Dumper:
         options = []
         varList = []
         watchers = ""
-        resultVarName = ""
 
+        resultVarName = ""
         for arg in args.split(' '):
             pos = arg.find(":") + 1
             if arg.startswith("options:"):
@@ -1151,12 +1157,12 @@ class Dumper:
         self.passExceptions = "pe" in options
         self.autoDerefPointers = "autoderef" in options
         self.partialUpdate = "partial" in options
-        #self.ns = qqNs
         self.ns = qtNamespace()
-        try:
-            self.alienSource = catchCliOutput("info source")[0][-3:-1]==".d"
-        except:
-            self.alienSource = False
+        self.alienSource = False
+        #try:
+        #    self.alienSource = catchCliOutput("info source")[0][-3:-1]==".d"
+        #except:
+        #    self.alienSource = False
 
         #warn("NAMESPACE: '%s'" % self.ns)
         #warn("VARIABLES: %s" % varList)