mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-03-31 04:27:02 +00:00
2005-09-27 Mike Kestner <mkestner@novell.com>
* 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. svn path=/trunk/gtk-sharp/; revision=50884
This commit is contained in:
parent
a02ae2bfd6
commit
fede690a37
|
@ -1,3 +1,11 @@
|
|||
2005-09-27 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* 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 <christian.hergert@gmail.com>
|
||||
|
||||
* vte/Vte.metadata: Fix Vte.Terminal.SetColors to reflect proper mapping
|
||||
|
|
|
@ -36,35 +36,15 @@ namespace GLib {
|
|||
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 @@ namespace GLib {
|
|||
}
|
||||
set {
|
||||
if (_obj != IntPtr.Zero) {
|
||||
Opaques.Remove (_obj);
|
||||
Unref (_obj);
|
||||
if (owned)
|
||||
Free (_obj);
|
||||
|
@ -100,7 +79,6 @@ namespace GLib {
|
|||
_obj = value;
|
||||
if (_obj != IntPtr.Zero) {
|
||||
Ref (_obj);
|
||||
Opaques [_obj] = new WeakReference (this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ namespace GLib {
|
|||
|
||||
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)
|
||||
|
|
|
@ -363,7 +363,7 @@ public Pango.FontDescription FontDescription {
|
|||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue