I'm not surpsised it crashes as the code it tries to execute has been pulled away from under it's feet when the plugin was unloaded. The only thing I can think of is implementing the loading/unloading in a different plugin (as part of the same workgroup or addon) that implements a timer event with a minimal delay and a repetition counter of 1. Unloading the menu plugin would then arm the timer in the second plugin (which does not get unloaded) , making sure the menu plugin is reloaded through the executed timer code. Because timers are processed as part of the regular event loop (afaik), and there is only one such loop, it is always executed after everything else has been executed (except other, later armed timer events), which should avoid any race conditions. That's at least what's been working for me in the past for related stuff.
In the past, I've been able to reset custom Menus by isolating their init callbacks into a Plugin, then running: Application.UnloadPlugin(MenuPath) Application.LoadPlugin(MenuPath) which effectively resets the Menu. Now I have a situation where I need to be able to rebuild the Menu by running a callback item that lives within that same Menu. Obviously, Softimage doesn't like this, and crashes out to desktop if I try to Unload the Plugin from which the Plugin itself is being called. However, I thought there might be ways around this. I tried creating an Event that watches for when a Command has completed. Then I could run a command from that Menu, and it would be the Event, and not the Menu callback that does the Plugin Unload/Load. Sadly, this is also leading to a crash to desktop. Does anyone have a strategy for me to try? -B
-- ------------------------------------------- Stefan Kubicek Co-founder ------------------------------------------- keyvis digital imagery Wehrgasse 9 - GrĂ¼ner Hof 1050 Vienna Austria Phone: +43/699/12614231 --- www.keyvis.at ste...@keyvis.at --- -- This email and its attachments are --confidential and for the recipient only--