[PyQt] Segfault in QMenu.addAction when parent widget is deleted.

Phil Thompson phil at riverbankcomputing.com
Sat Apr 5 19:31:00 BST 2014


On 02-04-2014 9:11 pm, J Robert Ray wrote:
> Hi all, I wanted to share this small example program that will
> segfault.
>
> The newest PyQt I have been able to test it with PyQt 4.10 / Qt 
> 4.8.4,
> so I dont know if it has been fixed already.
>
> In boils down to trying to add a new action to a submenu of a menu
> attached to a widget that has been deleted. Were having this problem
> due to some asynchronous RPC and getting results back after a user 
> has
> caused the widget to go away.
>
> If anyone can try this in a newer PyQt to see if it still crashes, I
> would appreciate it.

It will always crash. The difference in behaviour is because the 'sub' 
menu is created by C++ and PyQt does not detect when it gets deleted.

Phil


More information about the PyQt mailing list