[PyQt] pyuic issue with 4.9.3

Phil Thompson phil at riverbankcomputing.com
Sun Jul 15 11:28:00 BST 2012


On Fri, 13 Jul 2012 09:02:30 -0400, Scott Kitterman <debian at kitterman.com>
wrote:
> On Friday, July 13, 2012 01:40:38 PM Phil Thompson wrote:
>> On Wed, 11 Jul 2012 20:07:46 -0400, Scott Kitterman
>> <debian at kitterman.com>
>> 
>> wrote:
>> > If you run "pyuic4 -o video_ui.py video.ui" with the two attached
>> > files,
>> > it
>> > works fine with 4.9.1, but fails with 4.9.3.  The error I get is:
>> > 
>> > Unknown Qt widget: Phonon.VideoPlayer
>> > 
>> > Was there a change that weboob (where the two files were taken from)
>> > needs to adapt to?
>> 
>> No, it's a bug - fixed in tonight's snapshot.
> 
> Great.  If you could give me the patch for this issue against 4.9.3,
> that'd be 
> a great help (I'm not going to get a newer version into Debian at this
> point, 
> so I need to deal in patches).  I can diff the snapshots, but it'd be
nice
> to 
> just have the patch.

Attached.

Phil
-------------- next part --------------


# HG changeset patch
# User Phil Thompson <phil at riverbankcomputing.com>
# Date 2012-07-13 13:39:28 +0100
# Node ID 29b668ada14c1428a3bbfe8f0324c6626bd5ac9a
# Parent  fd0f3da9d79ca9858d10a20c15fb85456cb832d7
Fixed a regression in pyuic's handling of custom widgets.

diff --git a/pyuic/uic/Compiler/qobjectcreator.py b/pyuic/uic/Compiler/qobjectcreator.py
--- a/pyuic/uic/Compiler/qobjectcreator.py
+++ b/pyuic/uic/Compiler/qobjectcreator.py
@@ -1,6 +1,6 @@
 #############################################################################
 ##
-## Copyright (C) 2011 Riverbank Computing Limited.
+## Copyright (C) 2012 Riverbank Computing Limited.
 ## Copyright (C) 2006 Thorsten Marek.
 ## All right reserved.
 ##
@@ -100,7 +100,6 @@
         assert widgetClass not in self._widgets 
         self._widgets[widgetClass] = (baseClass, module)
 
-
     def _resolveBaseclass(self, baseClass):
         try:
             for x in range(0, 10):
@@ -114,19 +113,17 @@
         except KeyError:
             raise ValueError("unknown baseclass %s" % baseClass)
         
-
     def search(self, cls):
         try:
-            self._usedWidgets.add(cls)
             baseClass = self._resolveBaseclass(self._widgets[cls][0])
             DEBUG("resolved baseclass of %s: %s" % (cls, baseClass))
-            
-            return type(cls, (baseClass,),
-                        {"module" : ""})
-        
         except KeyError:
             return None
 
+        self._usedWidgets.add(cls)
+
+        return type(cls, (baseClass, ), {"module" : ""})
+
     def _writeImportCode(self):
         imports = {}
         for widget in self._usedWidgets:
diff --git a/pyuic/uic/objcreator.py b/pyuic/uic/objcreator.py
--- a/pyuic/uic/objcreator.py
+++ b/pyuic/uic/objcreator.py
@@ -102,19 +102,26 @@
         self._modules.append(self._customWidgets)
 
     def createQObject(self, classname, *args, **kwargs):
-        # Handle scoped names, typically static factory methods.
-        parts = classname.split('.')
-        factory = self.findQObjectType(parts[0])
+        # Handle regular and custom widgets.
+        factory = self.findQObjectType(classname)
 
-        if factory is not None:
-            for part in parts[1:]:
-                factory = getattr(factory, part, None)
-                if factory is None:
-                    break
-            else:
-                return self._cpolicy.instantiate(factory, *args, **kwargs)
+        if factory is None:
+            # Handle scoped names, typically static factory methods.
+            parts = classname.split('.')
 
-        raise NoSuchWidgetError(classname)
+            if len(parts) > 1:
+                factory = self.findQObjectType(parts[0])
+
+                if factory is not None:
+                    for part in parts[1:]:
+                        factory = getattr(factory, part, None)
+                        if factory is None:
+                            break
+
+            if factory is None:
+                raise NoSuchWidgetError(classname)
+
+        return self._cpolicy.instantiate(factory, *args, **kwargs)
 
     def invoke(self, rname, method, args=()):
         return self._cpolicy.invoke(rname, method, args)


More information about the PyQt mailing list