On 10/02/2014 at 11:09, xxxxxxxx wrote:
Cinema 4D Version: 13,14,15
Platform: Windows ;
Language(s) : C++ ;
Currently I have one issue that I only can solve by (perhaps) violating some Maxon guidelines on how to write proper plugins.
My plugin has several helper objects, inserted into the document.
When the user removes, deletes, the tag, I of course want these helper objects to be removed too. But what if the user invokes an Undo command? Then the tag comes back - without helper objects.
So - here it goes:
Question 1) Why is Init() called when I delete the tag? For what purpose?
In the Free() method, I get a GelistNode* all right, as a function argument. But node->GetDocument() returns NULL. I need the document in order to add an Undo for the helper objects! Here I have perhaps violated the Maxon rules, by storing the doc as a global variable, at an earlier stage of the tag's life time, when the doc still was accessible. Now, this somehow works, but I feel it is not reliable.
Question 2) Is there a message / function that I have overlooked, where the tag is notified about it being removed, before the BaseDocument is over the horizon, out of reach?
How do you deal with this? If my tag is removed, there are in fact several operations I have to carry out, where I just need access to the document. BTW, I have no problems determining if Cinema 4D itself is closing down or not, because if, then the undo pointer in the doc is NULL, even if the doc itself still is hanging out there.