I did modified the Fl class to allow overwrite Fl::handle and now I can  
catch any non managed exception on the override Fl:handle, but I'm getting  
zombie windows when an exception is caught.

---- Fl.H
...

/** signature of main event handler */
typedef int (*Fl_Main_Event_Handler)(int e, Fl_Window* w);
...

   // event destinations:
   static Fl_Main_Event_Handler main_handle;
   static int default_main_handle(int, Fl_Window*);
   static int handle(int e, Fl_Window* w) {return (*main_handle)(e, w);};
...
----

----Fl.cxx
...

Fl_Main_Event_Handler Fl::main_handle = &Fl::default_main_handle;

int Fl::default_main_handle(int e, Fl_Window* window) //renamed Fl::handle  
to Fl::default_main_handle
...
----

-----
#include "app.h"
#include "sqlite3.h"
#include "i18n_function.h"

int my_handle_events(int event, Fl_Window* win)
{
     try
     {
         return Fl::default_main_handle(event, win);
     }
     catch(CppSqlException &e)
     {
         fl_alert(e.errorMessage());
     }
     catch(const char *e)
     {
         fl_alert(e);
     }
     catch(...)
     {
         fl_alert(_tr("Something unexpected happened, please ask your  
provider !"));
     }
     printf("Something unexpected happened, please ask your provider !\n");
     return 1;
}

int main(int argc, char **argv)
{
     sqlite3_enable_shared_cache(1);
     Fl_Input::default_number_format("\2,.");
     Fl::main_handle = &my_handle_events; //////// install my event handler  
to catch exceptions before return to operating system

     try
     {
         load_translations();

         //Fl::scheme("plastic");
         Fl::scheme("gtk+");
         //use partial match to find verdana font
         //Fl::visual(FL_RGB);
         //fltk.fl_register_images()
         set_app_font("erdana");

         Fl::add_focus_changing_handler(&fltk_Focus_Changing_Handler);

         //sqlite3 *db;
         //sqlite3_open("dadbiz.db", &db);
         MainWindow *win = new MainWindow();
#ifdef WIN32
         void *icon = (void *)LoadIcon(fl_display, "APP_ICON");
         if(icon) win->icon(icon);
#endif
         win->show(argc, argv);
         return Fl::run();
         delete win;
         //sqlite3_close(db);
     }
     catch(CppSqlException &e)
     {
         printf("%s\n", e.errorMessage());
         fl_alert(e.errorMessage());
     }
     catch(...)
     {
         printf("catch(...)\n");
         fl_alert(_tr("Something unexpected happened, please ask your  
provider !"));
     }
}
----
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to