Commits

Anonymous committed 0bccaee

repotreemodel: make XML reader work with PyQt 4.6 (CentOs 6.3)

Comments (0)

Files changed (1)

tortoisehg/hgqt/repotreemodel.py

 
 import os
 
+if PYQT_VERSION < 0x40700:
+    class LocalQXmlStreamReader(QXmlStreamReader):
+        def readNextStartElement(self):
+            while self.readNext() != QXmlStreamReader.Invalid:
+                if self.isEndElement():
+                    return False
+                elif self.isStartElement():
+                    return True
+            return False
+
+        def skipCurrentElement(self):
+            depth = 1
+            while depth > 0 and self.readNext() != QXmlStreamReader.Invalid:
+                if self.isEndElement():
+                    depth -= 1
+                elif self.isStartElement():
+                    depth += 1
+
+    QXmlStreamReader = LocalQXmlStreamReader
 
 extractXmlElementName = 'reporegextract'
 reporegistryXmlElementName = 'reporegistry'
     xw.writeEndDocument()
 
 def readXml(source, rootElementName):
-    if PYQT_VERSION < 0x40700:
-        return
     itemread = None
     xr = QXmlStreamReader(source)
     if xr.readNextStartElement():