On 24/06/2014 at 18:00, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 14
Platform: Mac OSX ;
Language(s) : C++ ;
---------
Let me see if I can explain the situation...
I have a DescriptionToolData plugin that includes a BUTTON in the Attribute Manager.
I check for the user clicking it in the Message method, with:
Bool cPolyPaintTool::Message(BaseDocument* doc, BaseContainer& data, LONG type, void* t_data)
{
BaseObject* obj=doc->GetActiveObject();
if (!obj) return TRUE;
if (type==MSG_DESCRIPTION_COMMAND)
{
DescriptionCommand *dc = static_cast<DescriptionCommand*>(t_data);
LONG button = dc->id[0].id;
if (button == MDATA_APPLY_BUTTON)
{
doc->StartUndo();
doc->AddUndo(UNDOTYPE_CHANGE, obj);
process_object(obj,data);
obj->Message(MSG_UPDATE);
EventAdd();
doc->EndUndo();
}
}
return TRUE;
}
Inside the process_object routine I adjust a few parameters inside the BaseContainer of the object. Actually, I just mess up with a BaseContainer that I created inside the object BaseContainer.
If I click the BUTTON it all goes fine. It works perfectly all the time.
But, as soon as I choose Undo, as soon as I click the BUTTON again, it hangs.
If I remove the:
doc->StartUndo();
doc->AddUndo(UNDOTYPE_CHANGE, obj);
...
doc->EndUndo();
It all works perfectly but, of course, I can't go back to the states before the changes made to the object.
Why could it be that a simple Undo can make it all go wrong?