<div dir="ltr">Hi, I have a strange crash in PyQt5 and I'm not sure if the error is in my buildscripts or in PyQt.<div>I have built Qt5, PyQt5 and SIP myself with msvc2010 / python 2.7</div><div><br></div><div>PyQt 5.4.1</div><div>Qt 5.4.1</div><div>SIP 4.16.7</div><div><br></div><div>My compiled version seems to work fine in almost all cases but I have this one crash that shows something went wrong.</div><div>Here's a minimal script that reproduce the crash (imports etc omitted):</div><div><br></div><div><div><i>a = PyQt5.QtWidgets.QApplication(sys.argv)</i></div><div><i>w = PyQt5.QtWidgets.QMainWindow();</i></div><div><i>res = w.menuBar().addMenu( PyQt5.QtWidgets.QMenu( "foo" ) )<br></i></div><div><i><br></i></div><div><i>print </i><i>res</i><i>                     # <---- PyQt5.QtWidgets.QAction object at 0x000000000279E3A8</i></div><div><i>sip.isdestroyed(res)    # <---- False</i></div><div><i>sip.ispyowned(res)     # <----- False</i></div><div><i>sip.dump(res)            # <----- Crash (res already destroyed in C++)</i></div></div><div><br></div><div><br></div><div>From what I can tell from debugging:</div><div>The QMenu instance passed to addMenu is deconstructed (both in python and in C++) before res is assigned in python.</div><div>The menu's QAction is destroyed in C++ during (or right after) the deconstruction of the QMenu but res is assigned a python instance of a QAction that thinks this C++ representation still exists.</div><div><br></div><div>I can <b>not </b>reproduce this crash with the prebuilt python 3.4 and the riverbank-pyqt5 binaries but I <b>can </b>reproduce it with any prebuilt "unofficial" pyqt5/python27 binaries I could find scattered around the internet. The crash is reproducible in both debug and non-debug builds.<br></div><div><br></div><div>Has anyone else encountered this or can confirm that their python27/pyqt5 version can run this code?</div><div><br></div><div>Thanks,</div><div>Johan</div></div>