Re: XForms: dynamically adding objects

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 21 Jul 99 19:48:32 PDT

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> ... for some reason the
> xforms objects can't be accessed after they are added to the form. ...

I'm not sure what you mean here. Do you mean they don't show up? Are
you calling fl_addto_form() and fl_end_form() when you create the objects?

The following is a snippet of code that adds an object (in this case a
Pixmapbutton) to a form:

fl_addto_form( fd_try->try );

obj = pobj[i] =
fl_add_pixmapbutton(FL_NORMAL_BUTTON,p[i],q[i],50,70,"");
fl_set_pixmap_data(obj,noname);
fl_set_object_callback(obj,delete_one_cb,i);

fl_end_form();

In this case, the code is pretty simpleminded, since I just quickly
crufted up an example. The callback here deletes the object.

> xforms objects can't be accessed after they are added to the form. I
> get the following error when I attempt to delete one:
> X Error of failed request: BadDrawable (invalid Pixmap or Window parameter)
> Major opcode of failed request: 62 (X_CopyArea)
> Resource id in failed request: 0x4400053
> Serial number of failed request: 1140
> Current serial number in output stream: 1414

When you delete the object are you hiding it? Here's a snippet of
code that deletes an pixmapbutton object:

fl_free_pixmapbutton_pixmap( ob ); /* Free the Pixmap first */

fl_hide_object( ob );
fl_delete_object( ob );
fl_free_object( ob );

pobj[data] = NULL;

> This leads me to believe that the object is not being properally copied
> into the structure.

I'm not sure what to suggest here. If you're assigning the object's
pointer into the structure, it should work.

The test example I whipped up worked correctly as many times as I
tried it but I didn't attempt to be especially clever.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/