Author: mkestner
Date: 2007-06-21 12:14:16 -0400 (Thu, 21 Jun 2007)
New Revision: 80492
Added:
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ExceptionManager.cs
Modified:
branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog
branches/gtk-sharp-2-468-branch/gtk-sharp/gdk/Input.custom
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/DelegateWrapper.cs
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Idle.cs
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Makefile.am
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ManagedValue.cs
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Object.cs
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Signal.cs
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Timeout.cs
branches/gtk-sharp-2-468-branch/gtk-sharp/glib/WeakObject.cs
branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/CellRenderer.custom
branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Container.custom
branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Input.custom
branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/NodeStore.cs
branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Widget.custom
Log:
2007-06-21 Mike Kestner <[EMAIL PROTECTED]>
* (glib|gdk|gtk)/* : port ExceptionManager feature back from trunk.
Adds try/catch blocks for all native to managed callbacks.
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog 2007-06-21 16:11:44 UTC
(rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/ChangeLog 2007-06-21 16:14:16 UTC
(rev 80492)
@@ -1,5 +1,10 @@
2007-06-21 Mike Kestner <[EMAIL PROTECTED]>
+ * (glib|gdk|gtk)/* : port ExceptionManager feature back from trunk.
+ Adds try/catch blocks for all native to managed callbacks.
+
+2007-06-21 Mike Kestner <[EMAIL PROTECTED]>
+
* gtk/TreePath.cs : port Equals fix back from trunk.
2007-06-21 Mike Kestner <[EMAIL PROTECTED]>
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/gdk/Input.custom
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/gdk/Input.custom 2007-06-21
16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/gdk/Input.custom 2007-06-21
16:14:16 UTC (rev 80492)
@@ -2,7 +2,7 @@
//
// Author: Mike Kestner <[EMAIL PROTECTED]>
//
-// Copyright (C) 2005 Novell, Inc.
+// Copyright (C) 2005, 2007 Novell, Inc.
//
// This code is inserted after the automatically generated code.
//
@@ -25,11 +25,15 @@
static void ReleaseGCHandle (IntPtr data)
{
- if (data == IntPtr.Zero)
- return;
+ try {
+ if (data == IntPtr.Zero)
+ return;
- GCHandle gch = (GCHandle) data;
- gch.Free ();
+ GCHandle gch = (GCHandle) data;
+ gch.Free ();
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
}
static InputDestroyNotify release_gchandle;
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/DelegateWrapper.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/DelegateWrapper.cs
2007-06-21 16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/DelegateWrapper.cs
2007-06-21 16:14:16 UTC (rev 80492)
@@ -96,10 +96,14 @@
// object that owned the native delegate wrapper no longer
// exists and the instance of the delegate itself is removed
from the hash table.
private void OnDestroy (IntPtr data) {
- lock (typeof (DelegateWrapper)) {
- if (instances.ContainsKey (this)) {
- instances.Remove (this);
+ try {
+ lock (typeof (DelegateWrapper)) {
+ if (instances.ContainsKey (this)) {
+ instances.Remove (this);
+ }
}
+ } catch (Exception e) {
+ ExceptionManager.RaiseUnhandledException (e,
false);
}
}
}
Added: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ExceptionManager.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ExceptionManager.cs
2007-06-21 16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ExceptionManager.cs
2007-06-21 16:14:16 UTC (rev 80492)
@@ -0,0 +1,74 @@
+// GLib.Application.cs - static Application class
+//
+// Authors: Mike Kestner <[EMAIL PROTECTED]>
+//
+// Copyright (c) 2007 Novell, Inc.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of version 2 of the Lesser GNU General
+// Public License as published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program; if not, write to the
+// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+
+namespace GLib {
+
+ using System;
+
+ public delegate void UnhandledExceptionHandler (UnhandledExceptionArgs
args);
+
+ public class UnhandledExceptionArgs :
System.UnhandledExceptionEventArgs {
+
+ bool exit_app = false;
+
+ public UnhandledExceptionArgs (Exception e, bool is_terminal) :
base (e, is_terminal) {}
+
+ public bool ExitApplication {
+ get {
+ return exit_app;
+ }
+ set {
+ if (value)
+ exit_app = value;
+ }
+ }
+ }
+
+ public class ExceptionManager {
+
+
+ private ExceptionManager () {}
+
+ public static event UnhandledExceptionHandler
UnhandledException;
+
+ public static void RaiseUnhandledException (Exception e, bool
is_terminal)
+ {
+ if (UnhandledException == null) {
+ Console.Error.WriteLine ("Exception in Gtk#
callback delegate");
+ Console.Error.WriteLine (" Note: Applications
can use GLib.ExceptionManager.UnhandledException to handle the exception.");
+ Console.Error.WriteLine (e);
+ Console.Error.WriteLine (new
System.Diagnostics.StackTrace (true));
+ Environment.Exit (1);
+ }
+
+ UnhandledExceptionArgs args = new
UnhandledExceptionArgs (e, is_terminal);
+ try {
+ UnhandledException (args);
+ } catch (Exception ex) {
+ Console.Error.WriteLine (ex);
+ Environment.Exit (1);
+ }
+
+ if (is_terminal || args.ExitApplication)
+ Environment.Exit (1);
+ }
+ }
+}
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Idle.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Idle.cs 2007-06-21
16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Idle.cs 2007-06-21
16:14:16 UTC (rev 80492)
@@ -31,21 +31,30 @@
public class Idle {
+ [CDeclCallback]
+ delegate bool IdleHandlerInternal ();
+
+
internal class IdleProxy : SourceProxy {
public IdleProxy (IdleHandler real)
{
real_handler = real;
- proxy_handler = new IdleHandler (Handler);
+ proxy_handler = new IdleHandlerInternal
(Handler);
}
public bool Handler ()
{
- IdleHandler idle_handler = (IdleHandler)
real_handler;
+ try {
+ IdleHandler idle_handler =
(IdleHandler) real_handler;
- bool cont = idle_handler ();
- if (!cont)
- Remove ();
- return cont;
+ bool cont = idle_handler ();
+ if (!cont)
+ Remove ();
+ return cont;
+ } catch (Exception e) {
+
ExceptionManager.RaiseUnhandledException (e, false);
+ }
+ return false;
}
}
@@ -54,12 +63,12 @@
}
[DllImport("libglib-2.0-0.dll")]
- static extern uint g_idle_add (IdleHandler d, IntPtr data);
+ static extern uint g_idle_add (IdleHandlerInternal d, IntPtr
data);
public static uint Add (IdleHandler hndlr)
{
IdleProxy p = new IdleProxy (hndlr);
- uint code = g_idle_add ((IdleHandler) p.proxy_handler,
IntPtr.Zero);
+ uint code = g_idle_add ((IdleHandlerInternal)
p.proxy_handler, IntPtr.Zero);
lock (Source.source_handlers)
Source.source_handlers [code] = p;
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Makefile.am
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Makefile.am 2007-06-21
16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Makefile.am 2007-06-21
16:14:16 UTC (rev 80492)
@@ -25,6 +25,7 @@
DelegateWrapper.cs \
DestroyNotify.cs \
EnumWrapper.cs \
+ ExceptionManager.cs \
FileUtils.cs \
GException.cs \
GString.cs \
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ManagedValue.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ManagedValue.cs
2007-06-21 16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/ManagedValue.cs
2007-06-21 16:14:16 UTC (rev 80492)
@@ -56,18 +56,28 @@
static IntPtr Copy (IntPtr ptr)
{
- if (ptr == IntPtr.Zero)
- return ptr;
- GCHandle gch = (GCHandle) ptr;
- return (IntPtr) GCHandle.Alloc (gch.Target);
+ try {
+ if (ptr == IntPtr.Zero)
+ return ptr;
+ GCHandle gch = (GCHandle) ptr;
+ return (IntPtr) GCHandle.Alloc (gch.Target);
+ } catch (Exception e) {
+ ExceptionManager.RaiseUnhandledException (e,
false);
+ }
+
+ return IntPtr.Zero;
}
static void Free (IntPtr ptr)
{
- if (ptr == IntPtr.Zero)
- return;
- GCHandle gch = (GCHandle) ptr;
- gch.Free ();
+ try {
+ if (ptr == IntPtr.Zero)
+ return;
+ GCHandle gch = (GCHandle) ptr;
+ gch.Free ();
+ } catch (Exception e) {
+ ExceptionManager.RaiseUnhandledException (e,
false);
+ }
}
public static IntPtr WrapObject (object obj)
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Object.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Object.cs 2007-06-21
16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Object.cs 2007-06-21
16:14:16 UTC (rev 80492)
@@ -339,15 +339,19 @@
void NotifyCallback (IntPtr handle, IntPtr pspec, IntPtr gch)
{
- GLib.Signal sig = ((GCHandle) gch).Target as
GLib.Signal;
- if (sig == null)
- throw new Exception("Unknown signal GC handle
received " + gch);
+ try {
+ GLib.Signal sig = ((GCHandle) gch).Target as
GLib.Signal;
+ if (sig == null)
+ throw new Exception("Unknown signal GC
handle received " + gch);
- NotifyArgs args = new NotifyArgs ();
- args.Args = new object[1];
- args.Args[0] = pspec;
- NotifyHandler handler = (NotifyHandler) sig.Handler;
- handler (GLib.Object.GetObject (handle), args);
+ NotifyArgs args = new NotifyArgs ();
+ args.Args = new object[1];
+ args.Args[0] = pspec;
+ NotifyHandler handler = (NotifyHandler)
sig.Handler;
+ handler (GLib.Object.GetObject (handle), args);
+ } catch (Exception e) {
+ ExceptionManager.RaiseUnhandledException (e,
false);
+ }
}
void ConnectNotification (string signal, NotifyHandler handler)
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Signal.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Signal.cs 2007-06-21
16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Signal.cs 2007-06-21
16:14:16 UTC (rev 80492)
@@ -56,11 +56,15 @@
delegate void SignalDestroyNotify (IntPtr data, IntPtr obj);
static void OnNativeDestroy (IntPtr data, IntPtr obj)
{
- GCHandle gch = (GCHandle) data;
- Signal s = gch.Target as Signal;
- s.DisconnectHandler (s.before_id);
- s.DisconnectHandler (s.after_id);
- gch.Free ();
+ try {
+ GCHandle gch = (GCHandle) data;
+ Signal s = gch.Target as Signal;
+ s.DisconnectHandler (s.before_id);
+ s.DisconnectHandler (s.after_id);
+ gch.Free ();
+ } catch (Exception e) {
+ ExceptionManager.RaiseUnhandledException (e,
false);
+ }
}
private Signal (GLib.Object obj, string signal_name, Delegate
marshaler)
@@ -173,12 +177,20 @@
static void voidObjectCallback (IntPtr handle, IntPtr gch)
{
- Signal sig = ((GCHandle) gch).Target as Signal;
- if (sig == null)
- throw new Exception ("Unknown signal class GC
handle received.");
+ try {
+ if (gch == IntPtr.Zero)
+ return;
+ Signal sig = ((GCHandle) gch).Target as Signal;
+ if (sig == null) {
+
ExceptionManager.RaiseUnhandledException (new Exception ("Unknown signal class
GC handle received."), false);
+ return;
+ }
- EventHandler handler = (EventHandler) sig.Handler;
- handler (Object.GetObject (handle), EventArgs.Empty);
+ EventHandler handler = (EventHandler)
sig.Handler;
+ handler (Object.GetObject (handle),
EventArgs.Empty);
+ } catch (Exception e) {
+ ExceptionManager.RaiseUnhandledException (e,
false);
+ }
}
static voidObjectDelegate event_handler_delegate;
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Timeout.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Timeout.cs 2007-06-21
16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/Timeout.cs 2007-06-21
16:14:16 UTC (rev 80492)
@@ -28,33 +28,41 @@
public class Timeout {
+ [CDeclCallback]
+ delegate bool TimeoutHandlerInternal ();
+
internal class TimeoutProxy : SourceProxy {
public TimeoutProxy (TimeoutHandler real)
{
real_handler = real;
- proxy_handler = new TimeoutHandler (Handler);
+ proxy_handler = new TimeoutHandlerInternal
(Handler);
}
public bool Handler ()
{
- TimeoutHandler timeout_handler =
(TimeoutHandler) real_handler;
+ try {
+ TimeoutHandler timeout_handler =
(TimeoutHandler) real_handler;
- bool cont = timeout_handler ();
- if (!cont)
- Remove ();
- return cont;
+ bool cont = timeout_handler ();
+ if (!cont)
+ Remove ();
+ return cont;
+ } catch (Exception e) {
+
ExceptionManager.RaiseUnhandledException (e, false);
+ }
+ return false;
}
}
private Timeout () {}
[DllImport("libglib-2.0-0.dll")]
- static extern uint g_timeout_add (uint interval, TimeoutHandler
d, IntPtr data);
+ static extern uint g_timeout_add (uint interval,
TimeoutHandlerInternal d, IntPtr data);
public static uint Add (uint interval, TimeoutHandler hndlr)
{
TimeoutProxy p = new TimeoutProxy (hndlr);
- uint code = g_timeout_add (interval, (TimeoutHandler)
p.proxy_handler, IntPtr.Zero);
+ uint code = g_timeout_add (interval,
(TimeoutHandlerInternal) p.proxy_handler, IntPtr.Zero);
lock (Source.source_handlers)
Source.source_handlers [code] = p;
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/glib/WeakObject.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/glib/WeakObject.cs
2007-06-21 16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/glib/WeakObject.cs
2007-06-21 16:14:16 UTC (rev 80492)
@@ -34,10 +34,14 @@
delegate void DestroyNotify (IntPtr data);
static void OnNativeDestroy (IntPtr data)
{
- GCHandle gch = (GCHandle) data;
- WeakObject obj = gch.Target as WeakObject;
- obj.Dispose ();
- gch.Free ();
+ try {
+ GCHandle gch = (GCHandle) data;
+ WeakObject obj = gch.Target as WeakObject;
+ obj.Dispose ();
+ gch.Free ();
+ } catch (Exception e) {
+ ExceptionManager.RaiseUnhandledException (e,
false);
+ }
}
void Dispose ()
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/CellRenderer.custom
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/CellRenderer.custom
2007-06-21 16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/CellRenderer.custom
2007-06-21 16:14:16 UTC (rev 80492)
@@ -36,20 +36,24 @@
static void GetSize_cb (IntPtr item, IntPtr widget, IntPtr
cell_area_ptr, IntPtr x_offset, IntPtr y_offset, IntPtr width, IntPtr height)
{
- CellRenderer obj = GLib.Object.GetObject (item, false)
as CellRenderer;
- Gtk.Widget widg = GLib.Object.GetObject (widget, false)
as Gtk.Widget;
- Gdk.Rectangle cell_area = Gdk.Rectangle.New
(cell_area_ptr);
- int a, b, c, d;
+ try {
+ CellRenderer obj = GLib.Object.GetObject (item,
false) as CellRenderer;
+ Gtk.Widget widg = GLib.Object.GetObject
(widget, false) as Gtk.Widget;
+ Gdk.Rectangle cell_area = Gdk.Rectangle.New
(cell_area_ptr);
+ int a, b, c, d;
- obj.GetSize (widg, ref cell_area, out a, out b, out c,
out d);
- if (x_offset != IntPtr.Zero)
- Marshal.WriteInt32 (x_offset, a);
- if (y_offset != IntPtr.Zero)
- Marshal.WriteInt32 (y_offset, b);
- if (width != IntPtr.Zero)
- Marshal.WriteInt32 (width, c);
- if (height != IntPtr.Zero)
- Marshal.WriteInt32 (height, d);
+ obj.GetSize (widg, ref cell_area, out a, out b,
out c, out d);
+ if (x_offset != IntPtr.Zero)
+ Marshal.WriteInt32 (x_offset, a);
+ if (y_offset != IntPtr.Zero)
+ Marshal.WriteInt32 (y_offset, b);
+ if (width != IntPtr.Zero)
+ Marshal.WriteInt32 (width, c);
+ if (height != IntPtr.Zero)
+ Marshal.WriteInt32 (height, d);
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
}
static void OverrideGetSize (GLib.GType gtype)
@@ -78,10 +82,14 @@
static void Render_cb (IntPtr item, IntPtr window, IntPtr
widget, ref Gdk.Rectangle background_area, ref Gdk.Rectangle cell_area, ref
Gdk.Rectangle expose_area, Gtk.CellRendererState flags)
{
- CellRenderer obj = GLib.Object.GetObject (item, false)
as CellRenderer;
- Gdk.Drawable wind = GLib.Object.GetObject (window,
false) as Gdk.Drawable;
- Gtk.Widget widg = GLib.Object.GetObject (widget, false)
as Gtk.Widget;
- obj.Render (wind, widg, background_area, cell_area,
expose_area, flags);
+ try {
+ CellRenderer obj = GLib.Object.GetObject (item,
false) as CellRenderer;
+ Gdk.Drawable wind = GLib.Object.GetObject
(window, false) as Gdk.Drawable;
+ Gtk.Widget widg = GLib.Object.GetObject
(widget, false) as Gtk.Widget;
+ obj.Render (wind, widg, background_area,
cell_area, expose_area, flags);
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
}
static void OverrideRender (GLib.GType gtype)
@@ -107,13 +115,19 @@
static IntPtr StartEditing_cb (IntPtr raw, IntPtr evnt, IntPtr
widget, IntPtr path, ref Gdk.Rectangle background_area, ref Gdk.Rectangle
cell_area, Gtk.CellRendererState flags)
{
- CellRenderer obj = GLib.Object.GetObject (raw, false)
as CellRenderer;
- Gdk.Event _event = new Gdk.Event (evnt);
- Widget widg = GLib.Object.GetObject (widget, false) as
Gtk.Widget;
- CellEditable retval = obj.StartEditing (_event, widg,
GLib.Marshaller.Utf8PtrToString (path), background_area, cell_area, flags);
- if (retval == null)
- return IntPtr.Zero;
- return retval.Handle;
+ try {
+ CellRenderer obj = GLib.Object.GetObject (raw,
false) as CellRenderer;
+ Gdk.Event _event = new Gdk.Event (evnt);
+ Widget widg = GLib.Object.GetObject (widget,
false) as Gtk.Widget;
+ CellEditable retval = obj.StartEditing (_event,
widg, GLib.Marshaller.Utf8PtrToString (path), background_area, cell_area,
flags);
+ if (retval == null)
+ return IntPtr.Zero;
+ return retval.Handle;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
+
+ return IntPtr.Zero;
}
static void OverrideStartEditing (GLib.GType gtype)
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Container.custom
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Container.custom
2007-06-21 16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Container.custom
2007-06-21 16:14:16 UTC (rev 80492)
@@ -145,9 +145,13 @@
static void ForallOld_cb (IntPtr container, bool include_internals, IntPtr cb,
IntPtr data)
{
- Container obj = GLib.Object.GetObject (container, false) as Container;
- CallbackInvoker invoker = new CallbackInvoker (cb, data);
- obj.ForAll (include_internals, invoker);
+ try {
+ Container obj = GLib.Object.GetObject (container, false) as
Container;
+ CallbackInvoker invoker = new CallbackInvoker (cb, data);
+ obj.ForAll (include_internals, invoker);
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException (e, false);
+ }
}
static void OverrideForallOld (GLib.GType gtype)
@@ -166,9 +170,13 @@
static void Forall_cb (IntPtr container, bool include_internals, IntPtr cb,
IntPtr data)
{
- Container obj = GLib.Object.GetObject (container, false) as Container;
- CallbackInvoker invoker = new CallbackInvoker (cb, data);
- obj.ForAll (include_internals, new Gtk.Callback (invoker.Invoke));
+ try {
+ Container obj = GLib.Object.GetObject (container, false) as
Container;
+ CallbackInvoker invoker = new CallbackInvoker (cb, data);
+ obj.ForAll (include_internals, new Gtk.Callback
(invoker.Invoke));
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException (e, false);
+ }
}
static void OverrideForall (GLib.GType gtype)
@@ -203,9 +211,15 @@
static IntPtr ChildType_cb (IntPtr raw)
{
- Container obj = GLib.Object.GetObject (raw, false) as Container;
- GLib.GType gtype = obj.ChildType ();
- return gtype.Val;
+ try {
+ Container obj = GLib.Object.GetObject (raw, false) as Container;
+ GLib.GType gtype = obj.ChildType ();
+ return gtype.Val;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException (e, false);
+ }
+
+ return GLib.GType.Invalid.Val;
}
static void OverrideChildType (GLib.GType gtype)
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Input.custom
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Input.custom 2007-06-21
16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Input.custom 2007-06-21
16:14:16 UTC (rev 80492)
@@ -29,10 +29,14 @@
public void NativeCallback (IntPtr data, int source,
int condition)
{
- IntPtr _arg0 = data;
- int _arg1 = source;
- Gdk.InputCondition _arg2 = (Gdk.InputCondition)
condition;
- managed ( _arg0, _arg1, _arg2);
+ try {
+ IntPtr _arg0 = data;
+ int _arg1 = source;
+ Gdk.InputCondition _arg2 =
(Gdk.InputCondition) condition;
+ managed ( _arg0, _arg1, _arg2);
+ } catch (Exception e) {
+
GLib.ExceptionManager.RaiseUnhandledException (e, false);
+ }
}
internal InputFunctionNative NativeDelegate;
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/NodeStore.cs
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/NodeStore.cs 2007-06-21
16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/NodeStore.cs 2007-06-21
16:14:16 UTC (rev 80492)
@@ -113,32 +113,49 @@
IntPtr get_column_type_cb (int col)
{
- return ctypes [col].Val;
+ try {
+ return ctypes [col].Val;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
+
+ return IntPtr.Zero;
}
bool get_node_cb (out int node_idx, IntPtr path)
{
- if (path == IntPtr.Zero)
- throw new ArgumentNullException ("path");
+ try {
+ if (path == IntPtr.Zero)
+ throw new ArgumentNullException
("path");
- TreePath treepath = new TreePath (path);
- node_idx = -1;
+ TreePath treepath = new TreePath (path);
+ node_idx = -1;
- ITreeNode node = GetNodeAtPath (treepath);
- if (node == null)
- return false;
+ ITreeNode node = GetNodeAtPath (treepath);
+ if (node == null)
+ return false;
- node_idx = node.ID;
- node_hash [node.ID] = node;
- return true;
+ node_idx = node.ID;
+ node_hash [node.ID] = node;
+ return true;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
+ node_idx = -1;
+ return false;
}
IntPtr get_path_cb (int node_idx)
{
- ITreeNode node = node_hash [node_idx] as ITreeNode;
- if (node == null) throw new Exception ("Invalid Node
ID");
+ try {
+ ITreeNode node = node_hash [node_idx] as
ITreeNode;
+ if (node == null) throw new Exception ("Invalid
Node ID");
- return GetPath (node).Handle;
+ return GetPath (node).Handle;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
+ return IntPtr.Zero;
}
[DllImport("libgobject-2.0-0.dll")]
@@ -146,125 +163,160 @@
void get_value_cb (int node_idx, int col, ref GLib.Value val)
{
- ITreeNode node = node_hash [node_idx] as ITreeNode;
- if (node == null)
- return;
- g_value_init (ref val, ctypes [col].Val);
- object col_val;
- if (getters [col] is PropertyInfo)
- col_val = ((PropertyInfo) getters
[col]).GetValue (node, null);
- else
- col_val = ((FieldInfo) getters [col]).GetValue
(node);
- val.Val = col_val;
+ try {
+ ITreeNode node = node_hash [node_idx] as
ITreeNode;
+ if (node == null)
+ return;
+ g_value_init (ref val, ctypes [col].Val);
+ object col_val;
+ if (getters [col] is PropertyInfo)
+ col_val = ((PropertyInfo) getters
[col]).GetValue (node, null);
+ else
+ col_val = ((FieldInfo) getters
[col]).GetValue (node);
+ val.Val = col_val;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
}
bool next_cb (ref int node_idx)
{
- ITreeNode node = node_hash [node_idx] as ITreeNode;
- if (node == null)
- return false;
+ try {
+ ITreeNode node = node_hash [node_idx] as
ITreeNode;
+ if (node == null)
+ return false;
- int idx;
- if (node.Parent == null)
- idx = Nodes.IndexOf (node);
- else
- idx = node.Parent.IndexOf (node);
+ int idx;
+ if (node.Parent == null)
+ idx = Nodes.IndexOf (node);
+ else
+ idx = node.Parent.IndexOf (node);
- if (idx < 0) throw new Exception ("Node not found in
Nodes list");
+ if (idx < 0) throw new Exception ("Node not
found in Nodes list");
- if (node.Parent == null) {
- if (++idx >= Nodes.Count)
- return false;
- node = Nodes [idx] as ITreeNode;
- } else {
- if (++idx >= node.Parent.ChildCount)
- return false;
- node = node.Parent [idx];
+ if (node.Parent == null) {
+ if (++idx >= Nodes.Count)
+ return false;
+ node = Nodes [idx] as ITreeNode;
+ } else {
+ if (++idx >= node.Parent.ChildCount)
+ return false;
+ node = node.Parent [idx];
+ }
+ node_hash [node.ID] = node;
+ node_idx = node.ID;
+ return true;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
}
- node_hash [node.ID] = node;
- node_idx = node.ID;
- return true;
+ return false;
}
bool children_cb (out int child_idx, int parent)
{
- child_idx = -1;
- ITreeNode node;
+ try {
+ child_idx = -1;
+ ITreeNode node;
- if (parent == -1) {
- if (Nodes.Count <= 0)
+ if (parent == -1) {
+ if (Nodes.Count <= 0)
+ return false;
+ node = Nodes [0] as ITreeNode;
+ child_idx = node.ID;
+ node_hash [node.ID] = node;
+ return true;
+ }
+
+ node = node_hash [parent] as ITreeNode;
+ if (node == null || node.ChildCount <= 0)
return false;
- node = Nodes [0] as ITreeNode;
- child_idx = node.ID;
- node_hash [node.ID] = node;
+
+ ITreeNode child = node [0];
+ node_hash [child.ID] = child;
+ child_idx = child.ID;
return true;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
}
-
- node = node_hash [parent] as ITreeNode;
- if (node == null || node.ChildCount <= 0)
- return false;
-
- ITreeNode child = node [0];
- node_hash [child.ID] = child;
- child_idx = child.ID;
- return true;
+ child_idx = -1;
+ return false;
}
bool has_child_cb (int node_idx)
{
- ITreeNode node = node_hash [node_idx] as ITreeNode;
- if (node == null || node.ChildCount <= 0)
- return false;
+ try {
+ ITreeNode node = node_hash [node_idx] as
ITreeNode;
+ if (node == null || node.ChildCount <= 0)
+ return false;
- return true;
+ return true;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
+ return false;
}
int n_children_cb (int node_idx)
{
- if (node_idx == -1)
- return Nodes.Count;
+ try {
+ if (node_idx == -1)
+ return Nodes.Count;
- ITreeNode node = node_hash [node_idx] as ITreeNode;
- if (node == null || node.ChildCount <= 0)
- return 0;
+ ITreeNode node = node_hash [node_idx] as
ITreeNode;
+ if (node == null || node.ChildCount <= 0)
+ return 0;
- return node.ChildCount;
+ return node.ChildCount;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
+ return 0;
}
bool nth_child_cb (out int child_idx, int parent, int n)
{
child_idx = -1;
- ITreeNode node;
+ try {
+ ITreeNode node;
- if (parent == -1) {
- if (Nodes.Count <= n)
+ if (parent == -1) {
+ if (Nodes.Count <= n)
+ return false;
+ node = Nodes [n] as ITreeNode;
+ child_idx = node.ID;
+ node_hash [node.ID] = node;
+ return true;
+ }
+
+ node = node_hash [parent] as ITreeNode;
+ if (node == null || node.ChildCount <= n)
return false;
- node = Nodes [n] as ITreeNode;
- child_idx = node.ID;
- node_hash [node.ID] = node;
+
+ ITreeNode child = node [n];
+ node_hash [child.ID] = child;
+ child_idx = child.ID;
return true;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
}
-
- node = node_hash [parent] as ITreeNode;
- if (node == null || node.ChildCount <= n)
- return false;
-
- ITreeNode child = node [n];
- node_hash [child.ID] = child;
- child_idx = child.ID;
- return true;
+ return false;
}
bool parent_cb (out int parent_idx, int child)
{
parent_idx = -1;
- ITreeNode node = node_hash [child] as ITreeNode;
- if (node == null || node.Parent == null)
- return false;
+ try {
+ ITreeNode node = node_hash [child] as ITreeNode;
+ if (node == null || node.Parent == null)
+ return false;
- node_hash [node.Parent.ID] = node.Parent;
- parent_idx = node.Parent.ID;
- return true;
+ node_hash [node.Parent.ID] = node.Parent;
+ parent_idx = node.Parent.ID;
+ return true;
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException
(e, false);
+ }
+ return false;
}
[DllImport("gtksharpglue-2")]
Modified: branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Widget.custom
===================================================================
--- branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Widget.custom 2007-06-21
16:11:44 UTC (rev 80491)
+++ branches/gtk-sharp-2-468-branch/gtk-sharp/gtk/Widget.custom 2007-06-21
16:14:16 UTC (rev 80492)
@@ -198,10 +198,14 @@
static void SetScrollAdjustments_cb (IntPtr widget, IntPtr hadj, IntPtr vadj)
{
- Widget obj = GLib.Object.GetObject (widget, false) as Widget;
- Gtk.Adjustment h = GLib.Object.GetObject (hadj, false) as
Gtk.Adjustment;
- Gtk.Adjustment v = GLib.Object.GetObject (vadj, false) as
Gtk.Adjustment;
- obj.OnSetScrollAdjustments (h, v);
+ try {
+ Widget obj = GLib.Object.GetObject (widget, false) as Widget;
+ Gtk.Adjustment h = GLib.Object.GetObject (hadj, false) as
Gtk.Adjustment;
+ Gtk.Adjustment v = GLib.Object.GetObject (vadj, false) as
Gtk.Adjustment;
+ obj.OnSetScrollAdjustments (h, v);
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException (e, false);
+ }
}
static void ConnectSetScrollAdjustments (GLib.GType gtype)
@@ -237,9 +241,13 @@
private static void BindingCallback (IntPtr handle, IntPtr user_data)
{
- Widget w = GLib.Object.GetObject (handle, false) as Widget;
- BindingInvoker invoker = ((GCHandle) user_data).Target as
BindingInvoker;
- invoker.Invoke (w);
+ try {
+ Widget w = GLib.Object.GetObject (handle, false) as Widget;
+ BindingInvoker invoker = ((GCHandle) user_data).Target as
BindingInvoker;
+ invoker.Invoke (w);
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException (e, false);
+ }
}
static BindingHandler binding_delegate;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches