Strange behavior with setter

I’m still working on my plugin and again I’m facing to something I can’t understand. I’ve defined setter and getter for some properties. When I try to populate these properties Xojo calls the setters with an empty string. This is clearly an issue with what I do. To make sure I compiled and tested CompleteClass exemple and the setter for MooseName works.

REALproperty DocPDF_Properties[] = {
    {"", "Author", "String", REALconsoleSafe, (REALproc)DocPDF_AuthorGetter, (REALproc)DocPDF_AuthorSetter},
    {"", "CreationDate", "DocumentDate", REALconsoleSafe, nil, (REALproc)DocPDF_CreationDateSetter},
    {"", "ModificationDate", "DocumentDate", REALconsoleSafe, nil, (REALproc)DocPDF_ModificationDateSetter}
};

What is strange is that if I change the type String to String111 for example or anything else Xojo IDE does not complain about an unknown type. The two setters with custom type DocumentDate work fine.

static void DocPDF_AuthorSetter(REALobject instance, REALstring info)
{
    REALstringData infodata;
    const char *author;
    
    ClassData(DocPDF_Definition, instance, DocPDF_Data, me);
    if (!(REALGetStringData(info, kREALTextEncodingUTF8, &infodata)))
        return;
    author = static_cast<const char *>(infodata.data);
    REALDisposeStringData(&infodata);
    ........
    ........
}

Everytime DocPDF_AuthorSetter is called info is null. I rebuild the plugin from scratch and emptied the Xojo cache.

Any clue would be much much appreciated !!! Thanks in advance.

Why don’t you have getters for CreationDate?

And you miss the “long param” parameter for the setter before the value.

I thought it wasn’t necessary for my needs.

Sorry. I don’t see what you mean.

The getter may be useful, maybe just for debugging.

And you need to use extra parameters for the implicit parameter:

static void DocPDF_AuthorSetter(REALobject instance, long param, REALstring info)

the param is the one defined in REALproperty structure and can be used to use the same C function for multiple parameters.

Indeed you’re right … as often. Now that works nicely.

Thanks again Christian

1 Like
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.