Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    iCustomDataType and GraphView- who owns the set pointer?

    Cinema 4D SDK
    c++
    2
    3
    724
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      cmpxchg8b
      last edited by cmpxchg8b

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

      https://developers.maxon.net/docs/cpp/2023_2/page_graphview_data_format.html

      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)?

      Cheers,
      -CMPX

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by

        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

        1 Reply Last reply Reply Quote 1
        • C
          cmpxchg8b
          last edited by

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

          -CMPX

          1 Reply Last reply Reply Quote 0
          • First post
            Last post