Fixed an issue in the Python debugger backends caused by forgotten check for PyQt5 type variables. 6_0_x

Fri, 20 Feb 2015 17:49:43 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 20 Feb 2015 17:49:43 +0100
branch
6_0_x
changeset 4120
6f0d4d279aeb
parent 4106
f367d432509a
child 4121
6ba94d73b4f9

Fixed an issue in the Python debugger backends caused by forgotten check for PyQt5 type variables.
(grafted from 3c9fa4b8869d22314e5547ab4cc7d838b9a578ce)

DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugClientBase.py file | annotate | diff | comparison | revisions
--- a/DebugClients/Python/DebugClientBase.py	Sun Feb 08 16:13:27 2015 +0100
+++ b/DebugClients/Python/DebugClientBase.py	Fri Feb 20 17:49:43 2015 +0100
@@ -1428,7 +1428,8 @@
                             exec 'mdict = dict%s.__dict__' % access
                             ndict.update(mdict)     # __IGNORE_WARNING__
                             exec 'obj = dict%s' % access
-                            if "PyQt4." in str(type(obj)):
+                            if "PyQt4." in str(type(obj)) or \
+                                    "PyQt5." in str(type(obj)):
                                 qtVariable = True
                                 qvar = obj
                                 qvtype = ("%s" % type(qvar))[1:-1]\
@@ -1454,7 +1455,8 @@
                             ndict.update(cdict)
                             exec 'obj = dict%s' % access
                             access = ""
-                            if "PyQt4." in str(type(obj)):
+                            if "PyQt4." in str(type(obj)) or \
+                                    "PyQt5." in str(type(obj)):
                                 qtVariable = True
                                 qvar = obj
                                 qvtype = ("%s" % type(qvar))[1:-1]\
@@ -1467,7 +1469,8 @@
                             ndict.update(dict[var[i]].__class__.__dict__)
                             del rvar[0]
                             obj = dict[var[i]]
-                            if "PyQt4." in str(type(obj)):
+                            if "PyQt4." in str(type(obj)) or \
+                                    "PyQt5." in str(type(obj)):
                                 qtVariable = True
                                 qvar = obj
                                 qvtype = ("%s" % type(qvar))[1:-1]\
@@ -1484,7 +1487,8 @@
                                     pass
                             ndict.update(cdict)
                             obj = dict[var[i]]
-                            if "PyQt4." in str(type(obj)):
+                            if "PyQt4." in str(type(obj)) or \
+                                    "PyQt5." in str(type(obj)):
                                 qtVariable = True
                                 qvar = obj
                                 qvtype = ("%s" % type(qvar))[1:-1]\
@@ -1496,7 +1500,7 @@
                 i += 1
             
             if qtVariable:
-                vlist = self.__formatQt4Variable(qvar, qvtype)
+                vlist = self.__formatQtVariable(qvar, qvtype)
             elif ("sipThis" in dict.keys() and len(dict) == 1) or \
                     (len(dict) == 0 and len(udict) > 0):
                 if access:
@@ -1507,8 +1511,8 @@
                 else:
                     qvar = udict[var[-1]]
                 qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1]
-                if qvtype.startswith("PyQt4"):
-                    vlist = self.__formatQt4Variable(qvar, qvtype)
+                if qvtype.startswith(("PyQt4", "PyQt5")):
+                    vlist = self.__formatQtVariable(qvar, qvtype)
                 else:
                     vlist = []
             else:
@@ -1522,11 +1526,11 @@
                     else:
                         qvar = udict[var[-1]]
                     qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1]
-                    if qvtype.startswith("PyQt4"):
+                    if qvtype.startswith(("PyQt4", "PyQt5")):
                         qtVariable = True
                 
                 if qtVariable:
-                    vlist = self.__formatQt4Variable(qvar, qvtype)
+                    vlist = self.__formatQtVariable(qvar, qvtype)
                 else:
                     # format the dictionary found
                     if dictkeys is None:
@@ -1559,7 +1563,7 @@
         self.write('%s%s\n' % (
             DebugProtocol.ResponseVariable, unicode(varlist)))
         
-    def __formatQt4Variable(self, value, vtype):
+    def __formatQtVariable(self, value, vtype):
         """
         Private method to produce a formated output of a simple Qt4/Qt5 type.
         
@@ -1609,12 +1613,12 @@
         elif qttype == 'QColor':
             varlist.append(("name", "str", "%s" % value.name()))
             r, g, b, a = value.getRgb()
-            varlist.append(("rgb", "int", "%d, %d, %d, %d" % (r, g, b, a)))
+            varlist.append(("rgba", "int", "%d, %d, %d, %d" % (r, g, b, a)))
             h, s, v, a = value.getHsv()
-            varlist.append(("hsv", "int", "%d, %d, %d, %d" % (h, s, v, a)))
+            varlist.append(("hsva", "int", "%d, %d, %d, %d" % (h, s, v, a)))
             c, m, y, k, a = value.getCmyk()
             varlist.append(
-                ("cmyk", "int", "%d, %d, %d, %d, %d" % (c, m, y, k, a)))
+                ("cmyka", "int", "%d, %d, %d, %d, %d" % (c, m, y, k, a)))
         elif qttype == 'QDate':
             varlist.append(("", "QDate", "%s" % value.toString()))
         elif qttype == 'QTime':
--- a/DebugClients/Python3/DebugClientBase.py	Sun Feb 08 16:13:27 2015 +0100
+++ b/DebugClients/Python3/DebugClientBase.py	Fri Feb 20 17:49:43 2015 +0100
@@ -1447,7 +1447,8 @@
                                  .format(access), globals(), loc)
                             mdict = loc["mdict"]
                             obj = loc["obj"]
-                            if "PyQt4." in str(type(obj)):
+                            if "PyQt4." in str(type(obj)) or \
+                                    "PyQt5." in str(type(obj)):
                                 qtVariable = True
                                 qvar = obj
                                 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
@@ -1480,7 +1481,8 @@
                                  globals(), loc)
                             obj = loc["obj"]
                             access = ""
-                            if "PyQt4." in str(type(obj)):
+                            if "PyQt4." in str(type(obj)) or \
+                                    "PyQt5." in str(type(obj)):
                                 qtVariable = True
                                 qvar = obj
                                 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
@@ -1492,7 +1494,8 @@
                             ndict.update(dict[var[i]].__class__.__dict__)
                             del rvar[0]
                             obj = dict[var[i]]
-                            if "PyQt4." in str(type(obj)):
+                            if "PyQt4." in str(type(obj)) or \
+                                    "PyQt5." in str(type(obj)):
                                 qtVariable = True
                                 qvar = obj
                                 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
@@ -1512,7 +1515,8 @@
                                     pass
                             ndict.update(loc["cdict"])
                             obj = dict[var[i]]
-                            if "PyQt4." in str(type(obj)):
+                            if "PyQt4." in str(type(obj)) or \
+                                    "PyQt5." in str(type(obj)):
                                 qtVariable = True
                                 qvar = obj
                                 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
@@ -1523,7 +1527,7 @@
                 i += 1
             
             if qtVariable:
-                vlist = self.__formatQt4Variable(qvar, qvtype)
+                vlist = self.__formatQtVariable(qvar, qvtype)
             elif ("sipThis" in dict.keys() and len(dict) == 1) or \
                     (len(dict) == 0 and len(udict) > 0):
                 if access:
@@ -1540,8 +1544,8 @@
                 else:
                     qvar = udict[var[-1]]
                 qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
-                if qvtype.startswith("PyQt4"):
-                    vlist = self.__formatQt4Variable(qvar, qvtype)
+                if qvtype.startswith(("PyQt4", "PyQt5")):
+                    vlist = self.__formatQtVariable(qvar, qvtype)
                 else:
                     vlist = []
             else:
@@ -1561,11 +1565,11 @@
                     else:
                         qvar = udict[var[-1]]
                     qvtype = str(type(qvar))[1:-1].split()[1][1:-1]
-                    if qvtype.startswith("PyQt4"):
+                    if qvtype.startswith(("PyQt4", "PyQt5")):
                         qtVariable = True
                 
                 if qtVariable:
-                    vlist = self.__formatQt4Variable(qvar, qvtype)
+                    vlist = self.__formatQtVariable(qvar, qvtype)
                 else:
                     # format the dictionary found
                     if dictkeys is None:
@@ -1604,7 +1608,7 @@
         self.write('{0}{1}\n'.format(
             DebugProtocol.ResponseVariable, str(varlist)))
         
-    def __formatQt4Variable(self, value, vtype):
+    def __formatQtVariable(self, value, vtype):
         """
         Private method to produce a formatted output of a simple Qt4/Qt5 type.
         
@@ -1654,15 +1658,15 @@
             varlist.append(("name", "str", "{0}".format(value.name())))
             r, g, b, a = value.getRgb()
             varlist.append(
-                ("rgb", "int",
+                ("rgba", "int",
                  "{0:d}, {1:d}, {2:d}, {3:d}".format(r, g, b, a)))
             h, s, v, a = value.getHsv()
             varlist.append(
-                ("hsv", "int",
+                ("hsva", "int",
                  "{0:d}, {1:d}, {2:d}, {3:d}".format(h, s, v, a)))
             c, m, y, k, a = value.getCmyk()
             varlist.append(
-                ("cmyk", "int",
+                ("cmyka", "int",
                  "{0:d}, {1:d}, {2:d}, {3:d}, {4:d}".format(c, m, y, k, a)))
         elif qttype == 'QDate':
             varlist.append(("", "QDate", "{0}".format(value.toString())))

eric ide

mercurial