hipo r150 - in trunk: . src
- From: bgarret svn gnome org
- To: svn-commits-list gnome org
- Subject: hipo r150 - in trunk: . src
- Date: Sun, 17 Feb 2008 15:51:44 +0000 (GMT)
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 <benoit garret_gnome gadz org>
* 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;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]