Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Solved: crash on exit on Win might be prevented by app.clipboard().dataChanged.disconnect()
bootchk last edited by
For the benefit of others, a mistake of mine, that might be common.
In my app, I connected clipboard().dataChanged to an app slot that enables a paste action owned by the menubar of the main window. Without disconnecting that signal, if the user had copied something to the clipboard, my app crashed on exit, on the Win platform (but not OSX or Linux?). Calling clipboard().dataChanged.disconnect() in a handler for aboutToQuit signal seems to fix it. I surmise that at least on the Win platform, the signal is emitted while the app is quitting/exiting, after the main window (that my signal handler is enabling) was already deleted. (It is strange that the signal is emitted at that time, since the clipboard data had actually NOT changed at that time. I suppose it is a quirk of the Win Vista platform.)
I connected dataChanged to a slot in the app object, but the slot accessed the main window object. I suppose if I had connected dataChanged to a slot in the main window object, when main window was deleted, Qt would have automatically disconnected.
I'm using PyQt. The crash occurred in the Python interpreter (python27.dll). I think the mistake is also relevant to C++ apps.