Help with coding pie menu with the undo function

Hello,

I made a simplified modification of the pie menu template that shipped with blender, to illustrate my issue,

Somehow, after running the script, i am unable to undo(ctrl+z), as it will crash blender instantly.

If anyone can point out which part of the script is crashing, that would be really helpful.

To replicate the same issue i have, you have to run script, choose roundcube, and you should see the cube being created, your next action should be ctrl+z (without clicking anywhere else or performing any other action).

Thanks.

pietests.py (1.4 KB)