Solved iCustomDataType and GraphView- who owns the set pointer?

I'm using the code detailed here to set a custom datatype value to an Xpresso port:

This seems to work fairly well in practice. I'll start by calling ::Alloc() on my iCustomDataType class to retrieve a new object pointer (since GvGetPortGeData() never seems to return anything on an out port unless I've just set it using GvSetPortGeData()), then feed it to a new GeData instance using the custom data type constructor + plugin ID, then give the GeData object to GvSetPortGeData(). This seems to work fine- I get success from the function and I can see my custom set value magically appear inside Xpresso on the result node (since I've implemented the string calculation type on my custom data type class).

What I'm wondering is this- who owns the original iCustomDataType object I had to create using ::Alloc()? Neither GeData nor the GraphView documents seem to offer any insight into this. Should I be calling the iCustomDataType::Free() method with my object pointer to free it after I've wrapped it up in GeData and passed that to GvSetPortGeData()? Or does GeData/GraphView effectively "own" that pointer from thereon after (assuming GvSetPortGeData() returns success)?


Hi CMPX and thanks for reaching us.

With regard to your question if you're using the same design shown in the page you've pointed above, the CustomDataTypeClass::ConvertGeDataToGv actually redirects the ownership of the source data to Cinema 4D assuming the GvSetPortGeData() succeeds.

Best, Riccardo

Awesome, that's exactly what I needed to know- thanks for the reply!