hi,
i write a toolplugin, alloc a baseobject in InitTool() ,the baseobject pointer is toolplugin private member. free baseobject in FreeTool .
it works fine when switch tool .but when i close cinema 4d, myplugin will be crash and show this ,
i thought maybe cinema 4d free all object auto when close(i know it will not case crash,but just try)? so i use "if(myobject != nullptr)"check if free baseobject,but it unuseful, crash again. Where did I go wrong?
hope your help!
class mytool : public ToolData
{
......
private:
BaseObject* myobject;
}
Bool mytool::InitTool(BaseDocument * doc, BaseContainer & data, BaseThread * bt)
{
this->myobject = BaseObject::Alloc(Onull);
doc->InsertObject(myobject, nullptr, false);
return true;
}
void mytool::FreeTool(BaseDocument * doc, BaseContainer & data)
{
BaseObject::Free(myobject);
}