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.
This commit is contained in:
Bertrand Lorentz 2014-07-05 15:52:56 +02:00
parent f5211acb74
commit 7ea0c4afaf

View File

@ -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)]