From 445fe3004684dd1c3a3506498b10b382eba85afa Mon Sep 17 00:00:00 2001 From: Brad Taylor Date: Tue, 22 Sep 2009 02:19:50 +0000 Subject: [PATCH] 2009-09-22 Brad Taylor * glib/Idle.cs: * glib/Timeout.cs: Make sure to remove the unmanaged reference to the delegate when we're disposed or finalized. In particular, this fixes a problem where GLib.Object's PerformQueuedUnrefs was being called after both the object and the handler had been GC'ed, resulting in a segfault. svn path=/trunk/gtk-sharp/; revision=142362 --- ChangeLog | 9 +++++++++ glib/Idle.cs | 19 +++++++++++++++++++ glib/Timeout.cs | 19 +++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/ChangeLog b/ChangeLog index c8bb7265d..dbda13884 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-09-22 Brad Taylor + + * glib/Idle.cs: + * glib/Timeout.cs: Make sure to remove the unmanaged reference to the + delegate when we're disposed or finalized. In particular, this fixes a + problem where GLib.Object's PerformQueuedUnrefs was being called after + both the object and the handler had been GC'ed, resulting in a + segfault. + 2009-09-16 Mike Kestner * gtk/Gtk.metadata: hide StatusIcon.GetGeometry for custom impl. diff --git a/glib/Idle.cs b/glib/Idle.cs index 184a2fab9..953cd7c7f 100755 --- a/glib/Idle.cs +++ b/glib/Idle.cs @@ -45,6 +45,25 @@ namespace GLib { proxy_handler = new IdleHandlerInternal (Handler); } + ~IdleProxy () + { + Dispose (false); + } + + public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + protected virtual void Dispose (bool disposing) + { + if (disposing) + Remove (); + + Source.Remove (ID); + } + public bool Handler () { try { diff --git a/glib/Timeout.cs b/glib/Timeout.cs index 9d1b5ea70..faedf50b9 100755 --- a/glib/Timeout.cs +++ b/glib/Timeout.cs @@ -42,6 +42,25 @@ namespace GLib { proxy_handler = new TimeoutHandlerInternal (Handler); } + ~TimeoutProxy () + { + Dispose (false); + } + + public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + protected virtual void Dispose (bool disposing) + { + if (disposing) + Remove (); + + Source.Remove (ID); + } + public bool Handler () { try {