Re: XForms: Spurious callback call

j.w.c.a. lokin (lokin@signaal.nl)
Mon, 18 Oct 1999 09:14:52 +0200

# To subscribers of the xforms list from "j.w.c.a. lokin" <lokin@signaal.nl> :

This is a multi-part message in MIME format.
--------------4F2B6785237B2B6FF490570B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Steve Lamont wrote:
>
> # To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :
>
> > Should an fl_hide_object() on an input object actually call the object callback
> > function? I noted that it does, since it makes my program crash.
>
> No, it shouldn't. I did a simple test and the callback was not called.
>
> Can you provide a simple example which exhibits the behavior?
>

See the attached file. Note that the call is done as part of a hide on
a group.
Waht TC said seems to make sense, but I can't see how I should check
from within
my callback. Or am I missing something somewhere?

-- 
-+- Jan Willem Lokin -+-
--------------4F2B6785237B2B6FF490570B
Content-Type: text/plain; charset=us-ascii; name="inpcb.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="inpcb.c"

#include <stdlib.h> #include "forms.h"

struct TrkChoice { FL_OBJECT *group, *input, *message, *id, *data; void (*callback) (void); };

static void chc_prev_func (FL_OBJECT *obj, long n) { fprintf (stderr, "%s (%p, %ld)\n", __FUNCTION__, obj, n); }

static void chc_input_func (FL_OBJECT *obj, long n) { fprintf (stderr, "%s (%p, %ld)\n", __FUNCTION__, obj, n); }

static void chc_next_func (FL_OBJECT *obj, long n) { fprintf (stderr, "%s (%p, %ld)\n", __FUNCTION__, obj, n); }

#define CHC_SET_CALLBACK(cb) \ fl_set_object_callback (obj, cb, 0); \ obj->u_vdata = this

struct TrkChoice *add_trk_choice (int x, int y, int w, int h) { struct TrkChoice *this = malloc (sizeof (struct TrkChoice)); FL_OBJECT *obj;

this->group = fl_bgn_group ();

obj = fl_add_button (FL_NORMAL_BUTTON, x+h, y, h, h, "@<"); CHC_SET_CALLBACK (chc_prev_func);

this->input = obj = fl_add_input (FL_INT_INPUT, x+h+h, y, w-h, h, ""); fl_set_input (obj, ""); CHC_SET_CALLBACK (chc_input_func);

obj = fl_add_button (FL_NORMAL_BUTTON, x+h+w, y, h, h, "@>"); CHC_SET_CALLBACK (chc_next_func);

fl_end_group ();

this->callback = 0;

return this; }

int main (int argc, char *argv[]) { FL_FORM *form; struct TrkChoice *this;

fl_initialize (&argc, argv, 0, 0, 0);

form = fl_bgn_form (FL_FLAT_BOX, 200, 50); this = add_trk_choice (0, 0, 60, 20); fl_end_form (); fl_show_form (form, FL_PLACE_FREE, FL_FULLBORDER, argv[0]); fl_hide_object (this->group); /* this is the offending call */ fl_do_forms ();

fprintf (stderr, " *** Unexpected fallthru ***\n"); return 0; }

--------------4F2B6785237B2B6FF490570B--

_________________________________________________ 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/