From 8900d1ccd7e3c6114c9b8054fb9c30497dfb488d Mon Sep 17 00:00:00 2001 From: Gonzalo Paniagua Javier Date: Fri, 7 Oct 2005 21:33:30 +0000 Subject: [PATCH] 2005-10-07 Gonzalo Paniagua Javier * glib/MainContext.cs: added a Depth property to p/invoke g_main_depth. * glib/Object.cs: (Dispose): immediately call g_object_unref without queueing when possible (MainContext.Depth > 0) and use Timeout.Add instead of Idle.Add to get our unref callback scheduled more reliably. svn path=/trunk/gtk-sharp/; revision=51448 --- ChangeLog | 8 ++++++++ glib/MainContext.cs | 6 ++++++ glib/Object.cs | 9 ++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1b6d7056c..f44909cdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-10-07 Gonzalo Paniagua Javier + + * glib/MainContext.cs: added a Depth property to p/invoke g_main_depth. + * glib/Object.cs: + (Dispose): immediately call g_object_unref without queueing when + possible (MainContext.Depth > 0) and use Timeout.Add instead of Idle.Add + to get our unref callback scheduled more reliably. + 2005-10-05 Mike Kestner * bootstrap : bump version for beta3. diff --git a/glib/MainContext.cs b/glib/MainContext.cs index 0d7b3ebb2..a56899bce 100644 --- a/glib/MainContext.cs +++ b/glib/MainContext.cs @@ -26,6 +26,12 @@ namespace GLib { public class MainContext { + [DllImport("libglib-2.0-0.dll")] + static extern int g_main_depth (); + public static int Depth { + get { return g_main_depth (); } + } + [DllImport("libglib-2.0-0.dll")] static extern bool g_main_context_iteration (IntPtr Raw, bool MayBlock); diff --git a/glib/Object.cs b/glib/Object.cs index 7662a9967..063515061 100644 --- a/glib/Object.cs +++ b/glib/Object.cs @@ -80,11 +80,18 @@ namespace GLib { return; disposed = true; + if (MainContext.Depth > 0) { + g_object_unref (_obj); + Objects.Remove (_obj); + GC.SuppressFinalize (this); + return; + } + lock (PendingDestroys){ PendingDestroys.Add (this); lock (typeof (Object)){ if (!idle_queued){ - Idle.Add (new IdleHandler (PerformQueuedUnrefs)); + Timeout.Add (50, new TimeoutHandler (PerformQueuedUnrefs)); idle_queued = true; } }