[PyKDE] Problems with QWidgetFactory

Phil Thompson phil at riverbankcomputing.co.uk
Mon Jul 5 12:53:01 BST 2004


On Monday 05 July 2004 8:57 am, Fredrik Juhlin wrote:
> Hi,
>
> We've been working on making sure that our application works with the
> latest versions of Qt, SIP and PyQt (3.3.2, 4.0 and 3.12, respectively.)
> Doing that, we've come across a problem with QWidgetFactory.
>
> Something seems to happen to ownership of the widget returned by
> QWidgetFactory.create(). If one doesn't keep a reference to the widget it
> gets destroyed immediately, even if it is given a parent widget.
> At first I thought that maybe it was intentional (even though it doesn't
> work that way in older versions) but if we do keep a reference to the
> widget throughout its life, the program seg faults when the reference is
> cleaned up.
>
> In our application we use our own, subclassed widget factory to create
> special widgets, but I wrote a simple example using the built-in widget
> factory to demonstrate the behavior. The example is attached to this mail,
> along with a trivial .ui-file defining a widget with a QLineEdit and a
> QPushButton in a QVBoxLayout.
>
> The example code displays the behavior when not keeping a reference, but by
> commenting the chunk of code marked with 1. and de-commenting the chunk
> marked 2. the widget gets displayed but the app segfaults when it's about
> to exit.
>
> Any help on this matter would be much appreciated!

It's a SIP 4.0 bug. Patch attached and it will be fixed in tonight's snapshot. 
Thanks for the good test case.

I'm very interested in people's experience of moving to SIP 4. Let me know 
when you've completed your testing and I'll release 4.0.1.

Phil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: siplib.c.patch
Type: text/x-diff
Size: 729 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20040705/78d855ef/siplib.c.bin


More information about the PyQt mailing list