The way you've implemented doesn't allow to catch exceptions that are
recoverables and continue with the fltk application, when I proposed this
patch the idea is to override Fl::handle not and call the overridden
method inside a try {} catch {}, your implementation doesn't allow it.
We need to call Fl::handle, not be called by it !
------ original patch
Index: FL/Fl.H
===================================================================
--- FL/Fl.H (revision 8292)
+++ FL/Fl.H (working copy)
@@ -104,6 +104,9 @@
/** signature of args functions passed as parameters */
typedef int (*Fl_Args_Handler)(int argc, char **argv, int &i);
+/** signature of main event handler */
+typedef int (*Fl_Main_Event_Handler)(int e, Fl_Window* w);
+
/** @} */ /* group callback_functions */
@@ -682,8 +685,10 @@
static int test_shortcut(Fl_Shortcut);
// event destinations:
- static int handle(int, Fl_Window*);
- /** Gets the widget that is below the mouse.
+ 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);};
+ /** Gets the widget that is below the mouse.
\see belowmouse(Fl_Widget*) */
static Fl_Widget* belowmouse() {return belowmouse_;}
static void belowmouse(Fl_Widget*);
Index: src/Fl.cxx
===================================================================
--- src/Fl.cxx (revision 8292)
+++ src/Fl.cxx (working copy)
@@ -972,7 +972,9 @@
return ret;
}
-int Fl::handle(int e, Fl_Window* window)
+Fl_Main_Event_Handler Fl::main_handle = &Fl::default_main_handle;
+
+int Fl::default_main_handle(int e, Fl_Window* window)
/**
Sends the event to a window for processing. Returns non-zero if any
widget uses the event.
------
----
//if any exception is thrown by our fltk application during event handling
//we can catch it here and if appropriate inform the user, make a log and
continue running
//!!!!! we need to call Fl::handle, not be called by it
int my_handle_events(int event, Fl_Window* win)
{
try
{
return Fl::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 !"));
}
return 1;
}
int main()
{
// we need to override the original Fl::handle
// to wrap it with a try {} catch)() {}
Fl::main_handle = &my_handle_events;
...
return Fl::run();
}
----
En 25/01/2011 20:56:12, Matthias Melcher <[email protected]> escribió:
>
> [STR Closed w/Resolution]
>
> Link: http://www.fltk.org/str.php?L2532
> Version: 1.3-feature
> Fix Version: 1.3.0 (r8314)
>
>
> I implemented it slightly differently because I felt that this keeps the
> interface consistent. The naming "dispatch" is meant to keep users from
> trying to replace regular "handle()" functions by using this call. Hope
> you like it.
>
>
> Link: http://www.fltk.org/str.php?L2532
> Version: 1.3-feature
> Fix Version: 1.3.0 (r8314)
>
--
Usando el revolucionario cliente de correo de Opera:
http://www.opera.com/mail/
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev