[PyQt] Python has stopped working in PyQt application

Baz Walter bazwal at ftml.net
Tue Mar 31 17:00:52 BST 2015


On 31/03/15 13:24, Florian Bruhin wrote:
> * redstone-cold <redstone-cold at 163.com> [2015-03-31 09:45:49 +0800]:
>> code here
>> https://bpaste.net/show/7a73adda2a4b
>>
>>
>> After it  running for about half a minute ,then close the window,
>> then the "Python has stopped working" dialog pops up(you had better
>> try more than once. )
>>
>>   I wonder why this happen ?any solution to this ?
>
> Seems like the crash happens in QObject::thread() when exiting Python.
>
> It seems it doesn't happen anymore when doing:
>
>      import sip
>      sip.setdestroyonexit(False)
>
> See:
> http://pyqt.sourceforge.net/Docs/sip4/python_api.html#sip.setdestroyonexit
>
> This is also the default with PyQt5 where I also can't reproduce the
> crash.

Setting the mainwindow as the parent of the systrayicon will ensure the 
objects get deleted in the right order (for both PyQt4 and PyQt5, no 
matter what the state of setdestroyonexit is):

     self.trayIcon = QSystemTrayIcon(self)

-- 
Regards
Baz Walter



More information about the PyQt mailing list