From 256bc09aee6dab5cecbfb099276ff452fdeea8e2 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Thu, 16 Dec 2004 17:09:58 +0000 Subject: [PATCH] 2004-12-16 Tambet Ingo * glib/Opaque.cs : hold a weakref in the hash, not a strong ref. svn path=/trunk/gtk-sharp/; revision=37840 --- ChangeLog | 4 +++ doc/en/Gnome/Print.xml | 62 +------------------------------------- glib/Opaque.cs | 67 +++++------------------------------------- 3 files changed, 13 insertions(+), 120 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e222c307..cdbf7d177 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-12-16 Tambet Ingo + + * glib/Opaque.cs : hold a weakref in the hash, not a strong ref. + 2004-12-15 Mike Kestner * gnome/Gnome.metadata : resolve a collision that was causing diff --git a/doc/en/Gnome/Print.xml b/doc/en/Gnome/Print.xml index 7e9ea97a4..b1bbb01f4 100644 --- a/doc/en/Gnome/Print.xml +++ b/doc/en/Gnome/Print.xml @@ -133,66 +133,6 @@ class PrintSample To be added - - - Method - - Gtk.Widget - - - - - - - - To be added - a - a - a - a - To be added - - - - - Method - - Gtk.Widget - - - - - - - - To be added - a - a - a - a - To be added - - - - - Method - - Gtk.Widget - - - - - - - - To be added - a - a - a - a - To be added - - Method @@ -1339,4 +1279,4 @@ class PrintSample - \ No newline at end of file + diff --git a/glib/Opaque.cs b/glib/Opaque.cs index d69af7509..d0510909c 100644 --- a/glib/Opaque.cs +++ b/glib/Opaque.cs @@ -7,6 +7,7 @@ // Copyright (c) 2001 Bob Smith // Copyright (c) 2001 Mike Kestner // Copyright (c) 2002 Rachel Hestilow +// Copyright (c) 2004 Novell, Inc. // // This program is free software; you can redistribute it and/or // modify it under the terms of version 2 of the Lesser GNU General @@ -32,79 +33,35 @@ namespace GLib { public class Opaque : IWrapper { - // Private class and instance members IntPtr _obj; static Hashtable Opaques = new Hashtable(); - /// - /// GetObject Shared Method - /// - /// - /// - /// Used to obtain a CLI typed object associated with a - /// given raw object pointer. This method is primarily - /// used to wrap object references that are returned - /// by either the signal system or raw class methods that - /// return opaque struct references. - /// - /// - /// - /// The wrapper instance. - /// - public static Opaque GetOpaque(IntPtr o) { - Opaque obj = (Opaque)Opaques[o]; - if (obj != null) return obj; - return null; //FIXME: Call TypeParser here eventually. - } + WeakReference reference = (WeakReference) Opaques[(int)o]; + if (reference == null || !reference.IsAlive) + return null; + return (Opaque) reference.Target; + } + public Opaque () {} - /// - /// Opaque Constructor - /// - /// - /// - /// Creates an opaque wrapper from a raw object reference. - /// - public Opaque (IntPtr raw) { Raw = raw; } - /// - /// Raw Property - /// - /// - /// - /// The raw Opaque reference associated with this wrapper. - /// Only subclasses of Opaque can access this read/write - /// property. For public read-only access, use the - /// Handle property. - /// - protected IntPtr Raw { get { return _obj; } set { - Opaques [value] = this; + Opaques [value] = new WeakReference (this); _obj = value; } } - /// - /// Handle Property - /// - /// - /// - /// The raw Opaque reference associated with this object. - /// Subclasses can use Raw property for read/write - /// access. - /// - public IntPtr Handle { get { return _obj; @@ -119,14 +76,6 @@ namespace GLib { return (Handle == ((Opaque) o).Handle); } - /// - /// GetHashCode Method - /// - /// - /// - /// Calculates a hashing value. - /// - public override int GetHashCode () { return Handle.GetHashCode ();