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:
parent
83c45a60a0
commit
6334f60e2e
2 changed files with 12 additions and 3 deletions
|
@ -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>
|
2005-05-25 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* configure.in.in : remove crosspkgdir arg that causes trouble with
|
* configure.in.in : remove crosspkgdir arg that causes trouble with
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace GLib {
|
||||||
bool disposed = false;
|
bool disposed = false;
|
||||||
Hashtable data;
|
Hashtable data;
|
||||||
static Hashtable Objects = new Hashtable();
|
static Hashtable Objects = new Hashtable();
|
||||||
static Queue PendingDestroys = new Queue ();
|
static ArrayList PendingDestroys = new ArrayList ();
|
||||||
static bool idle_queued;
|
static bool idle_queued;
|
||||||
|
|
||||||
~Object ()
|
~Object ()
|
||||||
|
@ -67,6 +67,7 @@ namespace GLib {
|
||||||
Console.WriteLine ("Exception while disposing a " + o + " in Gtk#");
|
Console.WriteLine ("Exception while disposing a " + o + " in Gtk#");
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
Objects.Remove (o._obj);
|
||||||
o._obj = IntPtr.Zero;
|
o._obj = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -78,9 +79,8 @@ namespace GLib {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
disposed = true;
|
disposed = true;
|
||||||
Objects.Remove (_obj);
|
|
||||||
lock (PendingDestroys){
|
lock (PendingDestroys){
|
||||||
PendingDestroys.Enqueue (this);
|
PendingDestroys.Add (this);
|
||||||
lock (typeof (Object)){
|
lock (typeof (Object)){
|
||||||
if (!idle_queued){
|
if (!idle_queued){
|
||||||
Idle.Add (new IdleHandler (PerformQueuedUnrefs));
|
Idle.Add (new IdleHandler (PerformQueuedUnrefs));
|
||||||
|
@ -101,7 +101,11 @@ namespace GLib {
|
||||||
|
|
||||||
Object obj;
|
Object obj;
|
||||||
WeakReference weak_ref = Objects[o] as WeakReference;
|
WeakReference weak_ref = Objects[o] as WeakReference;
|
||||||
|
|
||||||
if (weak_ref != null && weak_ref.IsAlive) {
|
if (weak_ref != null && weak_ref.IsAlive) {
|
||||||
|
lock (PendingDestroys)
|
||||||
|
PendingDestroys.Remove (weak_ref.Target);
|
||||||
|
|
||||||
obj = weak_ref.Target as GLib.Object;
|
obj = weak_ref.Target as GLib.Object;
|
||||||
if (owned_ref)
|
if (owned_ref)
|
||||||
g_object_unref (obj._obj);
|
g_object_unref (obj._obj);
|
||||||
|
|
Loading…
Reference in a new issue