Closing Your Part
When the user closes the document containing your part, or when your part is deleted from its containing part, OpenDoc calls your part'sReleaseAllmethod, followed by itssomUninitmethod. (If, when closing a document, the user specifies that changes be saved, your part'sExternalizemethod is called beforeReleaseAll.)The ReleaseAll Method
TheReleaseAllmethod is inherited fromODPersistentObject. Its purpose is to ensure that all your part's references to other objects and ownership of shared resources are relinquished before your part is itself deleted from memory. As a minimum, your override of theReleaseAllmethod should
Your part should not write itself to storage from within its
- call the
Releasemethods of all reference-counted objects to which your part has references, including iterating through your part's private lists of embedded frames and display frames and releasing each one (at this point, all of them should have been released anyway)- remove any link specifications your part has written to the clipboard
- fulfill any promises your part has written to the clipboard
- relinquish all foci that your part owns
- clear the undo stack if your part has written any undo actions to it
- call the
BaseRemovedmethod of any of your part's extensions- call the
PartRemovedmethod of any embedded-frames iterators your part has created
ReleaseAllmethod.Your part's
Releasemethod, inherited fromODRefCntObject, is called under different circumstances fromReleaseAll. For information on implementing aReleasemethod, see the section "Reference-Counted Objects"The somUninit Method
After it completesReleaseAll, your part receives no subsequent method calls except to its System Object Model (SOM) object destructorsomUninit. ThesomUninitmethod is inherited from thesomObjectclass of SOM; when you subclassODPart, you must overridesomUninit.Your
somUninitmethod should dispose of any storage created for your part object by thesomInitmethod and any other storage related to additional instance variables of your part initialized during execution. In this method, do not perform any tasks that could fail.