Hi,

I'm wondering if calling a callback from another callback
is a safe thing and what to give exactly as first argument.
Here's an example of kind of things I use to do:

class MyClass : public Fl_Double_Window
{
  Fl_Button *btn1, *btn2;

  ...

 public:

   MyClass(int w, int h, const char *l, int argc, char *argv[])
   : Fl_Double_Window(w, h, l)
   {

    ...

    btn1->callback(btn1_cb, this);
    btn2->callback(btn2_cb, this);
   }

  ...

  static void btn1_cb(Fl_Widget *w, void *data);
  static void btn2_cb(Fl_Widget *w, void *data);
};


void MyClass::btn1_cb(Fl_Widget *w, void *data)
{
  //some code I'll need in the next callback...
}


void MyClass::btn2_cb(Fl_Widget *w, void *data)
{
  MyClass *p = (MyClass*)data;
  p->btn1_cb(0, data);
 //or even: p->btn1_cb(w, data);
}

This code seems to work but I'm not sure there's no any hidden risk(s)
in giving zero or 'w' as first argument.

Can anybody tells me ?

Thanks

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to