On 15/09/2016 at 04:56, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 16
Platform: Windows ;
Language(s) : C++ ;
---------
Hi,
I have an object with a BITMAPBUTTON defined in the description. I am setting the bitmap in MSG_DESCRIPTION_GETBITMAP. However, creating the object and letting the timeline play, my memory fills up continously.
This is the code (there is no other code executed by the object except for GetDParameter/SetDParameter...see below).
case MSG_DESCRIPTION_GETBITMAP:
{
DescriptionGetBitmap* dgb = static_cast<DescriptionGetBitmap*>(t_data);
switch(dgb->id[0].id)
{
case ID_BMPBUTTON:
{
AutoAlloc<BaseBitmap> bmp;
bmp->Init(500,100); bmp->Clear(255,255,255);
dgb->bmp = bmp.Release(); //removing this line stops the memory filling up
}
break;
}
}
break;
Bool TestObject::GetDParameter(GeListNode* node, const DescID& id, GeData& t_data, DESCFLAGS_GET& flags)
{
switch(id[0].id)
{
case ID_BMPBUTTON:
{
BitmapButtonStruct bbs(static_cast<BaseMaterial*>(node), id, m_dirty);
t_data = GeData(CUSTOMDATATYPE_BITMAPBUTTON,bbs);
flags |= DESCFLAGS_GET_PARAM_GET;
break;
}
}
return Base::GetDParameter(node, id, t_data, flags);
}
Bool TestObject::SetDParameter(GeListNode* node, const DescID& id, const GeData& t_data, DESCFLAGS_SET& flags)
{
switch(id[0].id)
{
case ID_BMPBUTTON:
m_dirty=0;
flags |= DESCFLAGS_SET_PARAM_SET;
break;
}
return Base::SetDParameter(node, id, t_data, flags);
}
The docs state:
Recipient should allocate a bitmap and assign this pointer. The sender must ensure that the bitmap is freed properly. (Normally this means that Cinema 4D does the freeing.)
Am I doing something wrong? I thought that I am the recipient and C4D is the sender (otherwise it makes no sense that c4d does the freeing). Also dgb->bmp is always nullptr when it jumps into MSG_DESCRIPTION_GETBITMAP, so I actually have to fill it myself.
Or should I have the bitmap in memory according to the object lifetime scope (i.e. allocate the bitmap as a class member...darn didn't try that yet, but it just got to my mind when writing this..checking right now. But how does c4d free it then?).
Thanks