XForms: "fl_reset_io_callback"

Tano Fotang. (M.Tano@Wirtschaft.FH-Wolfenbuettel.DE)
Fri, 11 Jul 1997 18:17:28 -0700

To subscribers of the xforms list from "Tano Fotang." <M.Tano@Wirtschaft.FH-Wolfenbuettel.DE> :

hello,
lemme have 3 minutes of your time again. This one is LONGGG.
I use fdesign to set the parameters of object callbacks to (long)fdui.
Now a core dump results when one clicks on any of these objects.
the callback of each object is:
void my_object_cb(FL_OBJECT *ob, long fdui){
FD_myform form=(FD_myform *)fdui;
/* do things with the form */
}
The situation is a follows:
The application is supposed to monitor many servers, creating and
handling connections as follows:
my_fd=my_connect_to_server(my_server);
my_form=create_form_for_this_fd(my_fd); /*using fl_create_form etc */
fl_add_io_callback(my_fd, FL_READ, my_server_cb, (void*)my_form);
where: my_server_cb(int fd, void *data){
FD_myform *form=(FD_myform *)data;
/* do things with the form and data from fd*/
}

The forms (windows) are stored in a linked list.
i am connected to n servers and so i have n such windows on the screen.
Now i knock form k out of the list (fl_hide/free). All forms from k+1
produce now core dumps when my_server_cb is called, or when i click on
any
of the objects on them. However, evrything is fine with forms 1 thro
k-1. i dont know why.
My question: is it possible to change the data that was passed earlier
on
to fl_add_io_callback? e.g.
fl_reset_io_callback(my_fd, FL_READ, my_server_cb, (void*)new_data).

That way, i can reset the callback for all forms from k+1 to n
immediately after destroying form k:
for i=k+1 to n
fl_reset_io_callback(fd[i], FL_READ,my_server_cb,(void*)form[i]
I am convinced that this would end my troubles because i now have a
rather unelegant solution that works: it passes (void *)0 to
fl_io_callback, doesnt use fdesign's (long)fdui in object callbacks,
and does the following each time my_form is created:
obj1->u_vdata=(void*)my_form;
obj2->u_vdata=(void*)my_form;
...
objn->u_vdata=(void*)my_form;
where obj1,..,objn are the objects on the form.
This step is repeated again for forms k+1 to n after form k has been
freed! So if u have 20 forms and 30 objects on each, then u do that
600 times. it works but looks really silly and is very unflexible.

I'd be very happy to have an easier solution. Thank u. Fotang.
xforms 0.86
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/