diff --git a/ChangeLog b/ChangeLog index 7062214bc..ec9cb8ffe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-02-28 Mike Kestner + + * glib/Idle.cs : add locking on the source_handlers. + * glib/Source.cs : add locking on the source_handlers. + * glib/Timeout.cs : add locking on the source_handlers. + 2005-02-25 Mike Kestner * glib/Source.cs : remove from the hash by key. diff --git a/glib/Idle.cs b/glib/Idle.cs index 735837f67..306053a39 100755 --- a/glib/Idle.cs +++ b/glib/Idle.cs @@ -60,7 +60,8 @@ namespace GLib { { IdleProxy p = new IdleProxy (hndlr); uint code = g_idle_add ((IdleHandler) p.proxy_handler, IntPtr.Zero); - Source.source_handlers [code] = p; + lock (Source.source_handlers) + Source.source_handlers [code] = p; return code; } @@ -73,17 +74,19 @@ namespace GLib { bool result = false; ArrayList keys = new ArrayList (); - foreach (uint code in Source.source_handlers.Keys){ - IdleProxy p = Source.source_handlers [code] as IdleProxy; + lock (Source.source_handlers) { + foreach (uint code in Source.source_handlers.Keys) { + IdleProxy p = Source.source_handlers [code] as IdleProxy; - if (p != null && p.real_handler == hndlr) { - keys.Add (code); - result = g_source_remove_by_funcs_user_data (p.proxy_handler, IntPtr.Zero); + if (p != null && p.real_handler == hndlr) { + keys.Add (code); + result = g_source_remove_by_funcs_user_data (p.proxy_handler, IntPtr.Zero); + } } - } - foreach (object key in keys) - Source.source_handlers.Remove (key); + foreach (object key in keys) + Source.source_handlers.Remove (key); + } return result; } diff --git a/glib/Source.cs b/glib/Source.cs index 9b44261dd..8fc38e3e0 100644 --- a/glib/Source.cs +++ b/glib/Source.cs @@ -35,11 +35,13 @@ namespace GLib { internal void Remove () { ArrayList keys = new ArrayList (); - foreach (uint code in Source.source_handlers.Keys) - if (Source.source_handlers [code] == this) - keys.Add (code); - foreach (object key in keys) - Source.source_handlers.Remove (key); + lock (Source.source_handlers) { + foreach (uint code in Source.source_handlers.Keys) + if (Source.source_handlers [code] == this) + keys.Add (code); + foreach (object key in keys) + Source.source_handlers.Remove (key); + } real_handler = null; proxy_handler = null; } @@ -55,7 +57,8 @@ namespace GLib { public static bool Remove (uint tag) { - source_handlers.Remove (tag); + lock (Source.source_handlers) + source_handlers.Remove (tag); return g_source_remove (tag); } } diff --git a/glib/Timeout.cs b/glib/Timeout.cs index aa2218657..cc19142b8 100755 --- a/glib/Timeout.cs +++ b/glib/Timeout.cs @@ -55,7 +55,8 @@ namespace GLib { TimeoutProxy p = new TimeoutProxy (hndlr); uint code = g_timeout_add (interval, (TimeoutHandler) p.proxy_handler, IntPtr.Zero); - Source.source_handlers [code] = p; + lock (Source.source_handlers) + Source.source_handlers [code] = p; return code; }