Author: mkestner
Date: 2005-09-27 15:12:43 -0400 (Tue, 27 Sep 2005)
New Revision: 50884
Modified:
trunk/gtk-sharp/ChangeLog
trunk/gtk-sharp/glib/Opaque.cs
trunk/gtk-sharp/glib/Value.cs
trunk/gtk-sharp/gtk/Style.custom
Log:
2005-09-27 Mike Kestner <[EMAIL PROTECTED]>
* glib/Opaque.cs : remove the Opaques hash. As f-spot demonstrated,
we cannot rely on a pointer continuing to point at the same type in
memory, since there is no destroy notification for most opaques.
* glib/Value.cs : use more explicit GetOpaque overload.
* gtk/Style.custom : use more explicit GetOpaque overload.
Modified: trunk/gtk-sharp/ChangeLog
===================================================================
--- trunk/gtk-sharp/ChangeLog 2005-09-27 18:46:53 UTC (rev 50883)
+++ trunk/gtk-sharp/ChangeLog 2005-09-27 19:12:43 UTC (rev 50884)
@@ -1,3 +1,11 @@
+2005-09-27 Mike Kestner <[EMAIL PROTECTED]>
+
+ * glib/Opaque.cs : remove the Opaques hash. As f-spot demonstrated,
+ we cannot rely on a pointer continuing to point at the same type in
+ memory, since there is no destroy notification for most opaques.
+ * glib/Value.cs : use more explicit GetOpaque overload.
+ * gtk/Style.custom : use more explicit GetOpaque overload.
+
2005-09-24 Christian Hergert <[EMAIL PROTECTED]>
* vte/Vte.metadata: Fix Vte.Terminal.SetColors to reflect proper mapping
Modified: trunk/gtk-sharp/glib/Opaque.cs
===================================================================
--- trunk/gtk-sharp/glib/Opaque.cs 2005-09-27 18:46:53 UTC (rev 50883)
+++ trunk/gtk-sharp/glib/Opaque.cs 2005-09-27 19:12:43 UTC (rev 50884)
@@ -36,35 +36,15 @@
IntPtr _obj;
bool owned;
- // We don't have to do as much work here as
GLib.Object.GetObject
- // does; users can't subclass opaque types, so nothing bad will
happen
- // if we accidentally end up creating two wrappers for the same
object.
-
- static Hashtable Opaques = new Hashtable();
-
+ [Obsolete ("Use more explicit overload. This method always
returns null")]
public static Opaque GetOpaque (IntPtr o)
{
- WeakReference reference = (WeakReference) Opaques[o];
- if (reference == null)
- return null;
- if (!reference.IsAlive) {
- Opaques.Remove (o);
- return null;
- }
+ return null;
+ }
- return (Opaque) reference.Target;
- }
-
public static Opaque GetOpaque (IntPtr o, Type type, bool owned)
{
- Opaque opaque = GetOpaque (o);
- if (opaque != null) {
- if (owned)
- opaque.owned = true;
- return opaque;
- }
-
- opaque = (Opaque)Activator.CreateInstance (type, new
object[] { o });
+ Opaque opaque = (Opaque)Activator.CreateInstance (type,
new object[] { o });
if (owned) {
if (opaque.owned) {
// The constructor took a Ref it
shouldn't have, so undo it
@@ -92,7 +72,6 @@
}
set {
if (_obj != IntPtr.Zero) {
- Opaques.Remove (_obj);
Unref (_obj);
if (owned)
Free (_obj);
@@ -100,7 +79,6 @@
_obj = value;
if (_obj != IntPtr.Zero) {
Ref (_obj);
- Opaques [_obj] = new WeakReference
(this);
}
}
}
Modified: trunk/gtk-sharp/glib/Value.cs
===================================================================
--- trunk/gtk-sharp/glib/Value.cs 2005-09-27 18:46:53 UTC (rev 50883)
+++ trunk/gtk-sharp/glib/Value.cs 2005-09-27 19:12:43 UTC (rev 50884)
@@ -269,7 +269,7 @@
public static explicit operator GLib.Opaque (Value val)
{
- return GLib.Opaque.GetOpaque (g_value_get_boxed (ref
val));
+ return GLib.Opaque.GetOpaque (g_value_get_boxed (ref
val), (Type) new GType (val.type), false);
}
public static explicit operator GLib.Boxed (Value val)
Modified: trunk/gtk-sharp/gtk/Style.custom
===================================================================
--- trunk/gtk-sharp/gtk/Style.custom 2005-09-27 18:46:53 UTC (rev 50883)
+++ trunk/gtk-sharp/gtk/Style.custom 2005-09-27 19:12:43 UTC (rev 50884)
@@ -363,7 +363,7 @@
if (Raw == IntPtr.Zero)
return null;
- Pango.FontDescription ret = (Pango.FontDescription)
GLib.Opaque.GetOpaque (Raw);
+ Pango.FontDescription ret = (Pango.FontDescription)
GLib.Opaque.GetOpaque (Raw, typeof (Pango.FontDescription), false);
if (ret == null)
ret = new Pango.FontDescription (Raw);
return ret;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches