Free() causes a crash
-
On 09/06/2014 at 17:16, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 14
Platform: Mac OSX ;
Language(s) : C++ ;---------
My tag plugin hides all the faces of a polygonal object.
I want it to unhide all the faces if the plugin is deleted (or moved to another object, but that is not so important).
So, inside the Free method, I wrote the following:void polypaint::Free(GeListNode* node)
{
BaseTag *tag=(BaseTag* ) node;
BaseObject *op=tag->GetObject();
ModelingCommandData cd;
cd.doc = doc_store;
cd.op = op;
cd.mode = MODELINGCOMMANDMODE_POLYGONSELECTION;
cd.flags = MODELINGCOMMANDFLAGS_0;
SendModelingCommand(MCOMMAND_UNHIDE, cd);
EventAdd(EVENT_0);
return;
}doc_store is a public variable in my tag class that stores the current document (from within the Draw method), since I read that trying to get the document using the usual methods, returns a NULL inside the Free method.
But, as soon as I delete the tag, Cinema4D crashes.
This is the exact same code that I'm using somewhere inside the Draw method and all is going fine.
What could be happening to result in a crash? -
On 10/06/2014 at 03:34, xxxxxxxx wrote:
Ok, found it. I wasn't being able to get the op, so I just stored it as a public variable, just like the doc and it worked.