[PyKDE] Segmentation Fault: new-style objects

Ulrich Berning ulrich.berning at desys.de
Fri Feb 6 13:19:01 GMT 2004


Uwe Mayer schrieb:

>Hi,
>
>I was asked to report this behaviour to the "PyQt Folks" and this is the best 
>adress I could come up with. :)
>
>Using multiple inheritance with one predecessor being a Qt widget and the 
>other being a new-style class causes a segmentation fault upon instanciating 
>the combined child class.
>
>-- example --
>from qt import QWidget, QApplication
>import sys
>
>class A:
>    def __init__(self):
>        print "in A"
>
>class B(object):
>    def __init__(self):
>        print "in B"
>
>class C(QWidget,A):
>    def __init__(self):
>        QWidget.__init__(self)
>        A.__init__(self)
>        print "in C"
>
>class D(QWidget,B):
>    def __init__(self):
>        QWidget.__init__(self)
>        B.__init__(self)
>
>app = QApplication(sys.argv)
>C() #works
>D() #fails
>-- example --
>
>The versions where this behaviour occurs:
>
>Python 2.3.3
>  
>
>>>>qt.PYQT_BUILD 
>>>>        
>>>>
>'180'
>  
>
>>>>qt.PYQT_VERSION
>>>>        
>>>>
>198656
>  
>
>>>>qt.PYQT_VERSION_STR
>>>>        
>>>>
>'3.8'
>
>  
>
This seems to work with recent snapshots of SIP and PyQt.

I use:

Qt-3.3.0
Python-2.3.3
sip-snapshot-20040205
PyQt-snapshot-20040202

Tested on Linux.

>Another thing I'd like to report:
>pyuic makes a mistake when compiling the source of Qt Designer interface file 
>when the widget in the .ui file contains a toolbar with a Spacer object.
>pyuic "forgetts" a "self." infront of the Toolbar object:
>
>-- snip --
>$ python LMCMain.py
>Traceback (most recent call last):
>  File "LMCMain.py", line 65, in ?
>    main = LMCMain()
>  File "LMCMain.py", line 39, in __init__
>    LMCMainBase.__init__(self, parent, name, fl)
>  File "/home/merkosh/Projekte/LMC/LMC/GUI/LMCMainBase.py", line 1721, in 
>__init__
>    QApplication.sendPostedEvents(Toolbar,QEvent.ChildInserted)
>NameError: global name 'Toolbar' is not defined
>-- snip --
>
>The lines in question yield:
>-- snip2 --
>        spacer = QSpacerItem(0,0,QSizePolicy.Expanding,QSizePolicy.Minimum)
>        QApplication.sendPostedEvents(Toolbar,QEvent.ChildInserted)
>        Toolbar.boxLayout().addItem(spacer)
>-- snip2 --
>
>In both cases this should be 
>        spacer = QSpacerItem(0,0,QSizePolicy.Expanding,QSizePolicy.Minimum)
>        QApplication.sendPostedEvents(self.Toolbar,QEvent.ChildInserted)
>        self.Toolbar.boxLayout().addItem(spacer)
>
>
>I hope you will find this information usefull. If you need any other 
>information, please feel free to contact me.
>
>Not to forgett: Thanks für PyQt!
>
>Ciao
>Uwe
>
>_______________________________________________
>PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
>http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>
>  
>
With my recent snapshot of PyQt, I get an error message from pyuic:

pyuic: File generated with too recent version of Qt Designer (3.3 vs. 3.3.0)


After changing the version from "3.3" to "3.3.0" in the .ui file, I get 
the following:

-- snip --
         = QSpacerItem(0,0,QSizePolicy.Expanding,QSizePolicy.Minimum)
        QApplication.sendPostedEvents(Toolbar,QEvent.ChildInserted)
        Toolbar.boxLayout().addItem()
-- snip --

A little bit different, but still a bug.


Ulli

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20040206/4aadcece/attachment.html


More information about the PyQt mailing list