Author: mkestner
Date: 2005-05-31 15:22:58 -0400 (Tue, 31 May 2005)
New Revision: 45267

Modified:
   trunk/gtk-sharp/ChangeLog
   trunk/gtk-sharp/glib/Object.cs
Log:

2005-05-31  Mike Kestner  <[EMAIL PROTECTED]>

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


Modified: trunk/gtk-sharp/ChangeLog
===================================================================
--- trunk/gtk-sharp/ChangeLog   2005-05-31 19:18:32 UTC (rev 45266)
+++ trunk/gtk-sharp/ChangeLog   2005-05-31 19:22:58 UTC (rev 45267)
@@ -1,3 +1,8 @@
+2005-05-31  Mike Kestner  <[EMAIL PROTECTED]>
+
+       * glib/Object.cs : rework the weakref release mechanism to avoid a
+       couple "resurrection" issues.
+
 2005-05-25  Mike Kestner  <[EMAIL PROTECTED]>
 
        * configure.in.in : remove crosspkgdir arg that causes trouble with

Modified: trunk/gtk-sharp/glib/Object.cs
===================================================================
--- trunk/gtk-sharp/glib/Object.cs      2005-05-31 19:18:32 UTC (rev 45266)
+++ trunk/gtk-sharp/glib/Object.cs      2005-05-31 19:22:58 UTC (rev 45267)
@@ -34,7 +34,7 @@
                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 @@
                                        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 @@
                                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 @@
 
                        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);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to