Plugin cleanup on Cinema exit?
On 08/11/2013 at 10:01, xxxxxxxx wrote:
Cinema 4D Version:
I need to properly clean my plugin state on Cinema exit. Is there a method I could hook to? I was hoping to get a notification in the NodeData::message method, I don't see it fire up on exit.
On 08/11/2013 at 10:51, xxxxxxxx wrote:
I use this one:
virtual void Free(GeListNode* node);
If you add this to your plugin's header, and implement it in the body, it is called by Cinema when you delete the plugin (if it is a tag) or when C4D closes the project.
Anyone who knows more on this topic?
On 08/11/2013 at 17:03, xxxxxxxx wrote:
That would be the best way. There or in a destructor method.
Also, it is essential that one implements Read/Write/CopyTo if data exists as members of your class that isn't in the container but needs to be retained. When Cinema 4D, for instance, renders a document, it copies your plugins (tags, objects, materials, etc.) with the document. If you have essential data or allocated memory in the class, it must be copied to the new copy (set or allocated and so on). When the user saves the document, this data needs to be written explicitly using Write() and then read back in using Read() - order specific.
On 10/11/2013 at 04:19, xxxxxxxx wrote:
The NodeData::Free() method is the officially most appropriate place to perform the clean up of
your Node's data. It is theoretically possible that the Init()/Free() pair is called multiple times on the
same instance in memory which is why these functions are more appropriate (though initializing
pointers to NULL is better be done in the constructor).
If you need to clean up global data, there is PluginEnd() as the "opposite" call to PluginStart().