THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/01/2008 at 13:10, xxxxxxxx wrote:
Quote: Originally posted by kuroyume0161 on 08 January 2008
>
> * * *
>
> What you're trying to do is a bit complicated - or, more specifically, a bit dangerous. CopyTo() is not only called when the user does a copy-paste but also when the document is being cache prepared or being copied for rendering. It is mainly used to maintain data not stored/handled by Cinema 4D (data other than BaseContainers and Descriptions) so that class elements can be copied as well, for instance.
>
>
>
> * * *
I am aware of CopyTo being called on many occasions and i think i did manage to handle that quite well. Haven't tried changing the object while rendering, which would obviously result in inaccurate rendering, but i guess i could exclude this and copied the object for that matter (as i do for copy/paste-ing the pluginobject in am)?
> Quote: __
>
> * * *
>
> So if this object is being stored and maintained by your plugin, that's okay as long as it isn't also being permanently added to the document (in the Object Manager for instance). Now Cinema 4D has ownership and you just have a pointer or link to it. This could end up being a bit dangerous. Now you say that it is a shared object between multiple instances of your plugin. That seems even more dangerous unless you restrict actions to the first instance and pass them down to the other instances as necessary.
>
>
>
> * * *
the object in question is an array of values, some sort of a cache that has to be shared between instances, since if it were copied it would be lost every time user would undo (as i understand this, if there is a way around this other then sharing the same object that would be even better). Copying is not an option since it uses quite a lot of memory.
> Quote: __
>
> * * *
>
> I'm not quite sure what you are trying to achieve. If this object is to be just one shared object for all instances, you'll definitely need a flag in the plugin that allocates one when none exists and doesn't allocate others afterwards. Then you'll have to pass this shared object around to new instances of your plugin. Again, not sure if this is correct understanding.
>
>
>
> * * *
This is correct. The object allocates only once, the problem is freeing it, since i have no idea when all the instances are gone (i think that might be when the document is closed, or even sooner if cinema has some undo limit, i'm not sure about that).
Thanks,
Cheers,
Miha