Changed so that Objects is a hash of

WeakReferences instead of hashing the real objects.  Without this
change, GObjects were never collected.
(Raw, set): Put a WeakReference to the object in Objects.
(Object.GetObject): Get the WeakReference from Objects, and from
there the actual object.
(Object.DisposeNative): Remove the Raw pointer from Objects.

svn path=/trunk/gtk-sharp/; revision=8578
This commit is contained in:
Ettore Perazzoli 2002-10-26 08:37:48 +00:00
parent 2e07bf7e87
commit cf139575c2
2 changed files with 18 additions and 4 deletions

View File

@ -1,3 +1,13 @@
2002-10-26 Ettore Perazzoli <ettore@ximian.com>
* glib/Object.cs: Changed so that Objects is a hash of
WeakReferences instead of hashing the real objects. Without this
change, GObjects were never collected.
(Raw, set): Put a WeakReference to the object in Objects.
(Object.GetObject): Get the WeakReference from Objects, and from
there the actual object.
(Object.DisposeNative): Remove the Raw pointer from Objects.
2002-10-26 Mike Kestner <mkestner@speakeasy.net>
* api/*.xml : get libgda and libgnomedb metadata setup

View File

@ -61,6 +61,8 @@ namespace GLib {
if (_obj == IntPtr.Zero)
return;
Objects.Remove (Raw);
GC.SuppressFinalize (this);
g_object_unref (_obj);
_obj = IntPtr.Zero;
@ -104,8 +106,9 @@ namespace GLib {
public static Object GetObject(IntPtr o)
{
Object obj = (Object)Objects[o];
if (obj != null) return obj;
WeakReference obj = Objects[o] as WeakReference;
if (obj != null)
return obj.Target as GLib.Object;
return GtkSharp.ObjectManager.CreateObject(o);
}
@ -117,7 +120,8 @@ namespace GLib {
/// Dummy constructor needed for derived classes.
/// </remarks>
public Object () {}
public Object () {
}
/// <summary>
/// Object Constructor
@ -148,7 +152,7 @@ namespace GLib {
return _obj;
}
set {
Objects [value] = this;
Objects [value] = new WeakReference (this);
_obj = value;
}
}