realbasic-plugins
[Top] [All Lists]

classNilObjectException on windows, but not on mac

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: classNilObjectException on windows, but not on mac
From: Alfred Van Hoek <vanhoek at mac dot com>
Date: Wed, 30 Mar 2005 17:52:05 -0500
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
Given the C++ class XMenuItem, which is a wrapper to "MenuItem" and is being
used to create a menuItem array depicting different colors. A plugin class
will expose these as a subclass of MenuItems to the user of the plugin.

The plugin defines a control, and one of its fields is the XMenuItem:

// the sample struct
typedef struct GuiseData {
    XMenuItem                    color;
} GuiseData;

// the sample getter
static REALobject Guise_TextColorMenuGet(REALobject instance)
{
    ControlData(GuiseClass, instance, GuiseData, data);
    data->color.lock();
    return data->color;
}

// the sample setter
static void Guise_TextColorMenuSet(REALobject instance, REALobject menu)
{
    ControlData(GuiseClass, instance, GuiseData, data);
    XMenuItem m = menu;

    if (!m) {
        data->color.unlock();
        return;
    }

    XMenuItem subm; // each subm will get different tag, text, name...

    subm = REALnewInstance("MenuItem");
    m.append(subm);
    subm.unlock();

    subm = REALnewInstance("MenuItem");
    m.append(subm);
    subm.unlock();

    subm = REALnewInstance("MenuItem");
    m.append(subm);
    subm.unlock();

    m.lock();
    data->color.unlock();
    data->color = m;
}

Declaration:

    {   (REALproc) Guise_TextColorMenuGet,
        (REALproc) Guise_TextColorMenuSet,
        "TextColorMenuItems() as GuiseMenuItem" },


In the open event of the plugin control the following is called:

  me.ColorMenuItems = new GuiseMenuItem
  me.ColorMenuItems.text = "Color"
  MenuBar1.append me.TextColorMenuItems

and this is ok for MacOS, but not for windows. On windows a
classNilObjectException is raised. Commenting out these lines will cure it,
so something seems to be wrong with the getter function, which is called
twice here.

What's wrong?

Alfred




   

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>