Crash-on-exit after call to app.processEvents()

Raymond Osborn rayosborn at mac.com
Mon May 25 18:48:01 BST 2020


I added a call to QtWidgets.QApplication.instance().processEvents() in order to force adjustResize() to work when switching tabs (that’s another story). It succeeded in fixing my resize issue, but now it triggers a segfault when I exit the application. This seemed to be related to the bug described in https://www.riverbankcomputing.com/static/Docs/PyQt5/gotchas.html#crashes-on-exit <https://www.riverbankcomputing.com/static/Docs/PyQt5/gotchas.html#crashes-on-exit>. One fix, suggested by @ekhumoro on stackoverflow (https://stackoverflow.com/questions/59120337/why-does-pyqt-sometimes-crash-on-exit <https://stackoverflow.com/questions/59120337/why-does-pyqt-sometimes-crash-on-exit>) was to delete the main window and the app first, but that doesn’t seem to fix it. I am running PyQt 5.12 because that is the last version supported by conda, so I can’t test the one-exit fix in v5.13, and my users probably wouldn’t have it installed anyway. It happens on Macs and linux.

What I am asking is if there are additional things to try in addition to @ekhumoro’s suggestion? Basically he suggests doing something like:

def main():
    app = QApplication(sys.argv)
    main_window = MainWindow()
    main_window.show()
    app.exec_()
    # ensure correct deletion order
    del main_window, app
Does anyone understand why the crash only occurs if I have calls to processEvents() in the code? It never happens when I remove them.

Thanks,
Ray

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20200525/cc9b92a3/attachment.htm>


More information about the PyQt mailing list