From 7ea0c4afaf405df2dfc5a42e098e9023ecc1c51c Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Sat, 5 Jul 2014 15:52:56 +0200 Subject: [PATCH] glib: Fix native GLib warnings when disposing SourceProxy objects When an instance of SourceProxy was finalized, we would try to remove the corresponding source, even if it was already removed. This now causes native GLib to print out warnings because it can't find the source ID. Now Source.Remove only calls g_source_remove if we really had a handler registered for the ID we're removing. --- glib/Source.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/glib/Source.cs b/glib/Source.cs index 2ab98e572..f810b5436 100644 --- a/glib/Source.cs +++ b/glib/Source.cs @@ -152,9 +152,15 @@ namespace GLib { public static bool Remove (uint tag) { - lock (Source.source_handlers) - source_handlers.Remove (tag); - return g_source_remove (tag); + // g_source_remove always returns true, so we follow that + bool ret = true; + + lock (Source.source_handlers) { + if (source_handlers.Remove (tag)) { + ret = g_source_remove (tag); + } + } + return ret; } [DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]