General XMetaL Discussion
Qing December 13, 2013 at 9:45 am
Close xmetal with multiple documents openDecember 13, 2013 at 9:45 amParticipants 2Replies 3Last Activity 9 years, 1 month ago
I met a problem with closing xmetal application (I am working with xmetal authoring essential 7.0).
If I just open one document, then close the xmetal, the run sequence of macros is: On_Document_Close and On_Applciation_Close. It's fine to me.
However, when there are multiple documents opened, and I click the close button, On_Document_Activate macro will run first.
I can understand this somehow, but my problem is that, On_Document_Activate in my customization will trigger the code to call web service to do query and then refresh the tool bar according to the result. When call web service and close xmetal happen together, the code refreshing tool bar which runs on UI thread will prevent it from ending which further hangs the xmetal process. That means that the xmetal ui close but not destroy and the process is still on.
I an wondering if there is anything I can do to check the current behavior is closing xmetal and then not trigger the macro the On_Document_Active?
Many Thanks.Qing December 16, 2013 at 1:47 am
Reply to: Close xmetal with multiple documents openDecember 16, 2013 at 1:47 am
Any one there? There question is so weird or I didn't make it clear?Derek Read December 16, 2013 at 10:37 pm
Reply to: Close xmetal with multiple documents openDecember 16, 2013 at 10:37 pm
I believe the general answer is that you need to make sure to release all COM objects you have instantiated and not rely on garbage collection to do that. Seems you understand this already and are just trying to figure out your own logic to do that. Tough one.
It sounds to me like you made some assumptions about when they need to be released and that you will need to change your logic so they can be released sooner. If they are being instantiated at a global variable level then you might have more flexibility on when you can release them. Just make sure that your release code always runs. If they are instantiated at the local level then you will want to release them as soon as they are no longer needed. That might mean they are instantiated and then released more often than in your original design.
One more thing: Be careful when modifying toolbars. Toolbar buttons should only be added or removed in the events named “On_Default_CommandBars_Complete” (for app-level/all-dtd changes) and “On_CommandBars_Load_Complete” (for dtd-specific commandbars). Direct toolbar modifications during other event macros are not supported. You can modify whether a macro is enabled or pushed in, which in turn affects whether a toolbar button (and or menu item) is greyed out or pushed in. You do this using DisableMacro() and PushInMacro() inside the On_Update_UI event. Don't try to make direct changes to the buttons themselves that mimic this behaviour.Qing December 17, 2013 at 1:55 am
Reply to: Close xmetal with multiple documents openDecember 17, 2013 at 1:55 am
Thanks for reply Derek.
It is really tough to figure out the right time and way to release all the com objects, and the web service interaction makes it even more tough.
So I just want to simplify it to see if there is any way to disable the document change macro when close the xmetal with multiple docs open. Is there any way to achieve this?
And I find a most simple way is the API Application.Quit(1) at the end of On_Application_Close macro and after the necessary release work.But, does this method secure?
- You must be logged in to reply to this topic.