Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Plugin cleanup on Cinema exit?

    SDK Help
    0
    4
    385
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 08/11/2013 at 10:01, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:    
      Platform:      
      Language(s) :

      ---------
      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.

      Thanks.

      --8

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            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().

            Best,
            -Niklas

            1 Reply Last reply Reply Quote 0
            • First post
              Last post