> at the bottom of main() what happens when the return (run()) is
> called? That is a really confusing one for me!

There's nothing really magical about
  return(Fl::run());
because it's just shorthand for
  int status = Fl::run();
  return(status);

In general, your program looks like this:
- initialize your GUI, data structures, comms, etc
- show at least one window on screen
- enter the event loop (ie: FL::run()

While there is at least one active window shown on the screen,
the event loop checks for window, mouse, and keyboard events and
once an event occurs, it invokes any callback(s) that may have
been registered for that event.

The event loop usually runs until the last window is closed, or
the program calls exit() somewhere [deep] in a callback function.
In the first case the Fl::run() call returns to the main program.
In the second the program is terminated immediately without
returning to main().

If you have some specific resources that need to be shutdown in
a particular way (eg comms protocol, or database session) you may
need to introduce some shutdown() routine before the exit() call
or to
  int status = Fl::run();
  shutdown();             // or status = shutdown();
  return(status);

Otherwise you can let the operating system automatically recover
resources as part of program termination: it's usually faster than
trying to do the resource recovery manually.

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

Reply via email to