Hello,
This is my very first step with FLTK and there are certainly many basic things I'm missing about this library.
My concern here is about object destruction.
The following mockup is created with FLUID. I have a added a destructor that is not called at all when the double window closes, with an exit code of 0.
On application exit, nothing is printed in stdout and the created directory persists. I would have expected the contrary.
I wish to know what's going on, how far is it normal and what should I consider to resolve this.
Using fltk 1.4.5-2 on Arch Linux.
Thank you for any guidance.
I got to deleting the main window in a handler, may be it's not the optimal way though:
// ----------------------------------------------------------------------------------------------static int OnMainWindowEvent(Fl_Widget * w, void * p)
{
int ev = Fl::event();
switch (ev)
{
case FL_CLOSE:
delete w;
return 0; // 0 or 1 ?
default:
std::cout << "Main window event: " << ev << std::endl;
break;
}
return 1;
}// ----------------------------------------------------------------------------------------------
I am happy to read the many more options you have listed;
and to note the reactivity of the forum.
So many more subtleties to discover yet.
Thank you all and regards.
Have fun with FLTK!
> cw->callback(OnMainWindowEvent, ...);
That's exactly it.
> but it doesn't remove your directory, does it?
No indeed. But in the real tiny app I'm working on, it's not UserInterface as in the mockup that is created from main, but a derived class of UserInterface, because the latter will always be modified by FLUID. Surprisingly after your comment and noting that you are right, the files that are created by the real app do disappear on exit with 'delete w', being explicitly removed in downwards destructors. They were not being removed without this handler. I'll still have to figure out why in this case, and not in the mockup.