Author: bgarret Date: Sun Feb 17 15:51:44 2008 New Revision: 150 URL: http://svn.gnome.org/viewvc/hipo?rev=150&view=rev
Log: 2008-02-17 Benoit Garret <[EMAIL PROTECTED]> * src/HipoMain.cs: catch glib exceptions Modified: trunk/ChangeLog trunk/src/HipoMain.cs Modified: trunk/src/HipoMain.cs ============================================================================== --- trunk/src/HipoMain.cs (original) +++ trunk/src/HipoMain.cs Sun Feb 17 15:51:44 2008 @@ -3,6 +3,7 @@ using Mono.Unix; using Gtk; using Glade; +using GLib; namespace Hipo { @@ -22,27 +23,60 @@ public void Run (string[] args) { - AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; + AppDomain.CurrentDomain.UnhandledException += AppUnhandledExceptionHandler; + GLib.ExceptionManager.UnhandledException += GlibUnhandledExceptionHandler; HipoMainWindow hmw = new HipoMainWindow (); hmw.CreateWindow (args); } - public void UnhandledExceptionHandler (object o, UnhandledExceptionEventArgs args) + public void AppUnhandledExceptionHandler (object o, UnhandledExceptionEventArgs args) { - Glade.XML gxml = new Glade.XML ("errordialog.glade", "errorDialog"); - - stackTrace = (TextView)gxml.GetWidget ("stackTrace"); - message = (Label)gxml.GetWidget ("message"); - errorDialog = (Dialog)gxml.GetWidget ("errorDialog"); + UnhandledExceptionHandler ((Exception)args.ExceptionObject); + } + + public void GlibUnhandledExceptionHandler (GLib.UnhandledExceptionArgs args) + { + UnhandledExceptionHandler ((Exception)args.ExceptionObject); + } + + public void UnhandledExceptionHandler (Exception e) + { + string stack = GetStackTrace (e); + string msg = GetMessage (e); - Exception e = (Exception) args.ExceptionObject; + Gtk.Application.Invoke (delegate { + + Glade.XML gxml = new Glade.XML ("errordialog.glade", "errorDialog"); + + stackTrace = (TextView)gxml.GetWidget ("stackTrace"); + message = (Label)gxml.GetWidget ("message"); + errorDialog = (Dialog)gxml.GetWidget ("errorDialog"); + + stackTrace.Buffer.Text = stack; + message.Text = msg; + errorDialog.Run (); + + errorDialog.Destroy (); + }); - stackTrace.Buffer.Text = e.StackTrace; - message.Text = e.Message; - errorDialog.Run (); + Application.RunIteration (); } + public string GetMessage (Exception e) + { + if (e.InnerException != null) + return String.Concat (e.Message, " : ", GetMessage (e.InnerException)); + else + return e.Message; + } + public string GetStackTrace (Exception e) + { + if (e.InnerException != null) + return String.Concat (GetStackTrace (e.InnerException), "\n::End of inner stack trace::\n", e.StackTrace); + else + return e.StackTrace; + } } } _______________________________________________ SVN-commits-list mailing list (read only) http://mail.gnome.org/mailman/listinfo/svn-commits-list Want to limit the commits to a few modules? Go to above URL, log in to edit your options and select the modules ('topics') you want. Module maintainer? It is possible to set the reply-to to your development mailing list. Email [EMAIL PROTECTED] if interested.