Allocation of PrefsDialogObject



  • Hi.

    Nice new forum. ^^

    While adapting my plugin for R20 I've been sifting through the code in order to get rid of all the red underlines vc++ throws at me. This is the last one:

    class SoloPrefs : public PrefsDialogObject
    {
    INSTANCEOF(SoloPrefs, PrefsDialogObject)

    public:
    virtual Bool InitValues(const DescID &id, Description* desc = NULL);

    virtual Bool Init(GeListNode* node);
    virtual Bool GetDParameter(GeListNode *node, const DescID &id, GeData &t_data, DESCFLAGS_GET &flags);
    virtual Bool SetDParameter(GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_SET &flags);
    virtual Bool GetDEnabling(GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_ENABLE flags, const BaseContainer *itemdesc);
    virtual Bool GetDDescription(GeListNode node, Description description, DESCFLAGS_DESC &flags);
    virtual Bool Message(GeListNode
    node, Int32 type, void
    data);

    BaseContainer *GetSoloPrefs();
    Int32 dirty;

    static NodeData *Alloc() { return gNew SoloPrefs; }
    };

    How to do the last line correctly? Thanks.



  • SOLVED
    It's just static NodeData *Alloc() { return NewObjClear(SoloPrefs); }


  • Global Moderator

    Hello,

    gNew was already removed and replaced in R15. See Changes for New Naming Scheme.

    NewObjClear() is deprecated and should only be used to handle old code.

    If you write new code, please use NewObj() and proper error handling. See Entity Creation.

    You find some example of handling the error in the microsdk example.

    Also, please use tags when creating a new post. See Read Before Posting.

    best wishes,
    Sebastian



  • In your specific example, it could look like this:

    static maxon::Result<NodeData*> Alloc() 
    {
        iferr_scope;
        return NewObj(SoloPrefs) iferr_return; 
    }
    

    And when you construct your NodeDataclass, you have to access the actual value of maxon::Result:

    SoloPrefs::Alloc().GetValue();
    

    Note, if that allocation fails that you can access the error with GetError().
    There have changed lots of things, Sebastian already posted the links to the relevant documentation.