2005-05-31 Mike Kestner <mkestner@novell.com>

* glib/Object.cs : rework the weakref release mechanism to avoid a
	couple "resurrection" issues.

svn path=/trunk/gtk-sharp/; revision=45267
This commit is contained in:
Mike Kestner 2005-05-31 19:22:58 +00:00
parent 83c45a60a0
commit 6334f60e2e
2 changed files with 12 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2005-05-31 Mike Kestner <mkestner@novell.com>
* glib/Object.cs : rework the weakref release mechanism to avoid a
couple "resurrection" issues.
2005-05-25 Mike Kestner <mkestner@novell.com>
* configure.in.in : remove crosspkgdir arg that causes trouble with

View file

@ -34,7 +34,7 @@ namespace GLib {
bool disposed = false;
Hashtable data;
static Hashtable Objects = new Hashtable();
static Queue PendingDestroys = new Queue ();
static ArrayList PendingDestroys = new ArrayList ();
static bool idle_queued;
~Object ()
@ -67,6 +67,7 @@ namespace GLib {
Console.WriteLine ("Exception while disposing a " + o + " in Gtk#");
throw e;
}
Objects.Remove (o._obj);
o._obj = IntPtr.Zero;
}
return false;
@ -78,9 +79,8 @@ namespace GLib {
return;
disposed = true;
Objects.Remove (_obj);
lock (PendingDestroys){
PendingDestroys.Enqueue (this);
PendingDestroys.Add (this);
lock (typeof (Object)){
if (!idle_queued){
Idle.Add (new IdleHandler (PerformQueuedUnrefs));
@ -101,7 +101,11 @@ namespace GLib {
Object obj;
WeakReference weak_ref = Objects[o] as WeakReference;
if (weak_ref != null && weak_ref.IsAlive) {
lock (PendingDestroys)
PendingDestroys.Remove (weak_ref.Target);
obj = weak_ref.Target as GLib.Object;
if (owned_ref)
g_object_unref (obj._obj);