[PyQt] Segfault on shutdown after adding a menu to a QMainWindow
Phil Thompson
phil at riverbankcomputing.com
Fri Mar 26 08:03:26 GMT 2010
On Thu, 25 Mar 2010 23:05:49 +0100, Philip Lorenz <lorenzph+sip at in.tum.de>
wrote:
> Hi,
>
> I am running PyQt 4.7.2 with Qt 4.6.2. When adding a menu to a
> QMainWindow the program segfaults on shutdown in the QApplication
> deconstructor (qapplication.sip - line 605). This seems to be caused by
> Qt as the newly added QMenu is listed in QApplication::topLevelWidgets()
> even though it has a parent set (therefore it should be deleted by Qt
> itself).
>
> The following example the segfault:
>
> from PyQt4.QtGui import *
> import sys
>
> app = QApplication(sys.argv)
> w = QMainWindow()
> w.show()
> # Adding the menu using w.menuBar().addMenu(QMenu("Test")) does not add
> it as a top level widget - hence resulting in no segfault on shutdown
> w.menuBar().addMenu("Test")
> # Prints QMainWindow as well as QMenu
> print QApplication.topLevelWidgets()
> app.exec_()
>
> Is this a bug within Qt or can anything be done inside PyQt to avoid
> this crash?
PyQt should take into account that there is a parent - it will be fixed in
tonight's snapshot.
Thanks,
Phil
More information about the PyQt
mailing list