On 17 Mar 2007, at 11:20, <[EMAIL PROTECTED]>  
<[EMAIL PROTECTED]> wrote:

> I rebuilded the code in a new project (just in case) but the  
> problem still occurs.
> I'm afraid there is a serious bug with XP pro. May be the bug  
> occurs just with the pro version of XP.... I really don't know.
> Does someone as any clue or idea ?

I don't have a usable XP setup to test on here, but I tried your code  
on my Mac and it seems mostly good.

BUT...

It looks as if (at least on OSX, anyway) that calling hide on a  
Fl_Group widget (or by extension an Fl_Window) will attempt to call  
hide() on any children of the group - *even if they have already been  
deleted*. At least, that's what gdb appears to be showing me... Your  
problem may be a variation of that issue?

Anyhow - the revised version of your code addresses that issue by  
using remove() to take the widget out of its parent group before  
deleting it.
That may be a solution for you? It is probably a Good Thing to do  
anyway, I would suggest.

Try my code, see how you get on.

----------
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>

class MyClass : public Fl_Window {
      Fl_Button *butt;
      Fl_Button *butt2;
      Fl_Box *box[99]; // should be a list, not an array but...
      int iBox; // "list" pointer...

      void my_callback(Fl_Widget *w)
      {
         begin();
         box[iBox] = new Fl_Box(10, 40, 100, 100);
         box[iBox]->box(FL_DOWN_BOX);
         box[iBox]->color((Fl_Color) iBox);
         iBox ++;
         end();
         redraw();
      }
      void my_callback2(Fl_Widget *w)
      {
                int idx = iBox - 1;
         if((idx >= 0) && (box[idx]))
         {
           box[idx]->hide();
           remove(box[idx]);
           Fl::delete_widget(box[idx]);
           box[idx] = (Fl_Box *)0;
           iBox --;
           redraw();
         }
      }
      static void my_static_callback(Fl_Widget *w, void *data) {
          ((MyClass*)data)->my_callback(w);
      }
      static void my_static_callback2(Fl_Widget *w, void *data) {
          ((MyClass*)data)->my_callback2(w);
      }
public:
      MyClass(int X, int Y):Fl_Window(X,Y) {
          butt = new Fl_Button(5,10,90,25,"Display");
          butt2 = new Fl_Button(105,10,90,25,"Clear");
          butt->callback(my_static_callback, (void*)this);
          butt2->callback(my_static_callback2, (void*)this);
          iBox = 0;
          box[0] = (Fl_Box *)0;
          end();
      }
};

int main(int argc, char **argv) {
      MyClass myclass(200,200);
      myclass.show(argc, argv);
      return Fl::run();
}

/* End of File */



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

Reply via email to