[PyKDE] Problem resolving widget's class
phil at riverbankcomputing.co.uk
Tue Nov 9 13:21:34 GMT 2004
> On Tuesday 02 November 2004 18.37, David Boddie wrote:
>> On Tue Nov 2 16:34 2004, Fredrik Juhlin wrote:
>> > On Tuesday 02 November 2004 16.07, David Boddie wrote:
>> > That's weird. I can run it for some time without getting an error.
>> > Do you get an error such as this:
>> > label label_test_17 (<__main__.qt.QWidget object at 0x400970ec>) isn't
>> > QLabel
>> > Traceback (most recent call last):
>> > File "test.py", line 39, in updateView
>> > self._updateLabels()
>> > File "test.py", line 60, in _updateLabels
>> > label.setText(label.name())
>> > AttributeError: setText
>> > Or do you get a different error all together?
>> I just get a segmentation fault. This is where we need to establish
>> versions of PyQt and SIP you're using. I'm using Python 2.3.4 with PyQt
>> 3.13 and SIP 4.0.
> As I stated in my initial mail, I run SIP 4.1.1, PyQt 3.13 and Python
> I looked at my test code and the more I thought of it, the more convinced
> got that using close(1) should be OK. But I rewrote it to use close() and
> deleteLater(). Since deleteLater() defers the delete, that should be safe
> Running the new version, the error actually occurs sooner than before for
> I attached the updated test.py to this mail, it would great if you could
> it and see if the error can be reproduced by you now.
This is a SIP bug. It's because Qt is destroying a QWidget instance and,
some time later, creating a QLabel instance at the same address. The
problem being that SIP/PyQt isn't noticing the destruction of the QWidget
and so assumes that the QLabel is the same instance.
I should have a fix in the next snapshot, which will be sometime around
Thanks for putting the effort into creating a such a good test case.
More information about the PyQt