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

    gNew deprecated, ok, but NewObj generates compiler error

    Cinema 4D SDK
    c++
    2
    3
    361
    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.
    • ingvaraiI
      ingvarai
      last edited by ingvarai

      Hi, I am working my way up from C4D R16, yes, I have all C4D Studio versions R13-R23, but I really want this to work.
      SDK = C4D R16
      Here is the code:

      /////// The customGUI's data class ///////////////
      class SliderData : public CustomGuiData
      {
          typedef CustomGuiData super;
          public:
          virtual Int32 GetId() { return LIBRAY_ID; }     //Gets the ID# we defined at the top for this gizmo
          virtual CDialog *Alloc(const BaseContainer &settings)
      	{
              // Next line compiler complains
      		GeDialog *dlg = gNew MyCustomGui(settings, GetPlugin());
      		if (!dlg) return NULL;
              return dlg->Get();
          }
      
          virtual void Free(CDialog *dlg, void *ud)
      	{
              if (dlg)
      		{
                  // Old does not work
      			//gDelete((GeDialog*&) dlg);   //Free the memory used by allocating dlg
                  
      			//New - no complaints
      			DeleteObj((GeDialog*&) dlg);	//Free the memory used by allocating dlg
              }
          }
      

      So my question is - how can I rewrite the line containing gNew, so that it works again? (Works fine in R14).
      I have tried with NewObj() and NewObjClear() - compiler still complains.
      -Ingvar

      1 Reply Last reply Reply Quote 0
      • C4DSC
        C4DS
        last edited by

        You create a custom GUI to display your custom data by deriving a class from iCustomGUI

        class iMyCustomGUI : public iCustomGui
        ...
        

        Then in you CustomGUIData derived class you implement the allocation by providing the derived iCustomGUI

        CDialog* ReferencePointCustomGUI::Alloc(const BaseContainer& settings)
        {
            iMyCustomGUI* dlg = NewObjClear(iMyCustomGUI, settings, GetPlugin());
            ...
        

        you can find more details in the R20 SDK example customdata_customgui.cpp in folder cinema4dsdk\source\gui
        Works OK for R16 upto at least R21 (I have not used/tested in more recent versions)

        1 Reply Last reply Reply Quote 0
        • ingvaraiI
          ingvarai
          last edited by

          Hi and thanks for this. It is my bad.. I didn't read the docs carefully enough / or did not understand the docs.
          Now this works!
          -Ingvar

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