[PyKDE] 3.2rc4 instability

Alan Harkreader alh at jenkon.com
Thu May 2 23:30:01 BST 2002


Looks like null pointer mischief.

=> in toggleWindow (posted example)

    self.centralWidget() # on a top-level-window (no parent)

=> in sipDo_QMainWindow_centralWidget

    res = sipCpp -> QMainWindow::centralWidget(); // res == NULL
    ...
    return sipMapCppToSelfSubClass(res,sipClass_QWidget); // res == NULL

=> in sipMapCppToSelfSubClass

    return sipMapCppToSelf(cppPtr,convertSubClass(pyClass,cppPtr)); // cppPtr == NULL

=> convertSubClass calls sipSubClass_QObject (as convertor)

=> sipSubClass_QObject

    PyQtGetQObjectPythonClass(sipCpp); // sipCpp == NULL

=> PyQtGetQObjectPythonClass

    ...
    sipMapStringToClass(qobj -> className(),...) // NULL->className(), Ouch! 


Difficult to get rtti from null. sipMapCppToSelf checks for NULL, 
(& returns None), problem is that convertSubClass call chain presumes valid QObject * (i.e., in 
PyQtGetQObjectPythonClass "qobj->className()") prior to sipMapCppToSelf.

Quick fix in sipMapCppToSelfSubClass -- avoid convertSubClass for NULL, & let sipMapCppToSelf
handle return None:

	return sipMapCppToSelf(cppPtr,cppPtr==NULL?pyClass:convertSubClass(pyClass,cppPtr));




4/29/2002 11:47:54 AM, brk at jenkon.com wrote:

>After upgrading from 3.1 to 3.2rc4 (Windows NT 4.0, sp6a, python 2.1.3, Qt
>3.0.3), I'm seeing a lot of new crashes on calls to simple methods like
>centralWidget() and parent(). Here's a simple example which crashes. Is
>anyone else having this sort of trouble?
>
>Thanks,
>
>Bryn
>
>---
>
>import sys
>import qt
>
>class MainWin(qt.QMainWindow):
>    def __init__(self):
>        qt.QMainWindow.__init__(self)
>        self.wnd = None
>        btn = qt.QPushButton('Click', self)
>        btn.resize(btn.sizeHint())
>        self.connect(btn, qt.SIGNAL('clicked()'), self.toggleWindow)
>
>    def toggleWindow(self):
>        self.centralWidget()
>        #self.parent()
>
>
>if __name__ == '__main__':
>    app = qt.QApplication(sys.argv)
>    win = MainWin()
>    win.show()
>    app.connect(app, qt.SIGNAL('lastWindowClosed()'), app,
>qt.SLOT('quit()'))
>    app.exec_loop()
>
>
>Bryn Keller
>Senior Software Engineer
>Jenkon
>brk at jenkon.com
>
>_______________________________________________
>PyKDE mailing list    PyKDE at mats.gmd.de
>http://mats.gmd.de/mailman/listinfo/pykde
>






More information about the PyQt mailing list