2005-02-25 Mike Kestner <mkestner@novell.com>

* glib/Source.cs : remove from the hash by key.
	* glib/Idle.cs : remove from the hash by key.

svn path=/trunk/gtk-sharp/; revision=41208
This commit is contained in:
Mike Kestner 2005-02-25 18:18:10 +00:00
parent 217c4a8429
commit 6d70444302
3 changed files with 27 additions and 9 deletions

View file

@ -1,3 +1,8 @@
2005-02-25 Mike Kestner <mkestner@novell.com>
* glib/Source.cs : remove from the hash by key.
* glib/Idle.cs : remove from the hash by key.
2005-02-23 Dan Winship <danw@novell.com>
* sources/gnomedb.patch: Patch over a bug in gnome-db-editor.h

View file

@ -24,6 +24,7 @@
namespace GLib {
using System;
using System.Collections;
using System.Runtime.InteropServices;
public delegate bool IdleHandler ();
@ -65,17 +66,26 @@ namespace GLib {
}
[DllImport("libglib-2.0-0.dll")]
static extern bool g_source_remove_by_funcs_user_data (IdleHandler d, IntPtr data);
static extern bool g_source_remove_by_funcs_user_data (Delegate d, IntPtr data);
public static bool Remove (IdleHandler hndlr)
{
bool result = false;
ArrayList keys = new ArrayList ();
foreach (uint code in Source.source_handlers.Keys){
IdleProxy p = (IdleProxy) Source.source_handlers [code];
IdleProxy p = Source.source_handlers [code] as IdleProxy;
if (p.real_handler == hndlr)
Source.source_handlers.Remove (p);
if (p != null && p.real_handler == hndlr) {
keys.Add (code);
result = g_source_remove_by_funcs_user_data (p.proxy_handler, IntPtr.Zero);
}
}
return g_source_remove_by_funcs_user_data (hndlr, IntPtr.Zero);
foreach (object key in keys)
Source.source_handlers.Remove (key);
return result;
}
}
}

View file

@ -34,7 +34,12 @@ namespace GLib {
internal void Remove ()
{
Source.source_handlers.Remove (this);
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);
real_handler = null;
proxy_handler = null;
}
@ -50,9 +55,7 @@ namespace GLib {
public static bool Remove (uint tag)
{
if (source_handlers.Contains (tag))
source_handlers.Remove (tag);
source_handlers.Remove (tag);
return g_source_remove (tag);
}
}