@Kovid,
Ok, I just gave the replace_action() a quick whirl and Calibre crashed in a big way (as in a C++/Qt style crash, no Python stack trace). I have a suspicion the Python code is trying to do something with a disposed Qt object?
So here is what I am doing:
The first time round, keyboard shortcut registered as per "normal", with a call to create_menu_action() and shortcut set to the required value
The second time menu is rebuilt, I do the following:
- call the clear() method on my Qt parent menu
- recreate the menu action doing the same call to create_menu_action(), except with shortcut=False
- build the right unique name. This was a bit of a copy/paste nasty, because the unique name that replace_action does it's key lookup by isn't the unique_name I supplied to create_menu_action(). So I replicate that unique_name = '%s : menu action : %s'%(ia.unique_name, unique_name) prior to calling replace_action
- then I call gui.keyboard.replace_action(unique_name, my_new_action)
At this point the big nasty happens.
|