glib/Object.cs: Rewrote the way the wrapper is kept track of.

svn path=/trunk/gtk-sharp/; revision=921
This commit is contained in:
Bob Smith 2001-09-21 16:24:46 +00:00
parent 3432779d13
commit 5056f3e4b3
2 changed files with 6 additions and 19 deletions

View File

@ -1,6 +1,7 @@
2001-09-21 2001-09-21
* Signal system totally reworked. It should be stable now. * Signal system totally reworked. It should be stable now.
* glib/Object.cs: Rewrote the way the wrapper is kept track of.
2001-09-20 2001-09-20

View File

@ -13,18 +13,11 @@ namespace GLib {
public class Object { public class Object {
protected static Hashtable Objects = new Hashtable(); protected static Hashtable Objects = new Hashtable();
protected const String GOBJECTKEY = "gobject#-object";
public static Object GetObject(IntPtr o) public static Object GetObject(IntPtr o)
{ {
IntPtr key = g_object_get_data (o, GOBJECTKEY); Object obj = (Object)Objects[(int)o];
Object obj;
if((int)key != 0)
{
obj = (Object)Objects[(int)key];
if (obj != null) return obj; if (obj != null) return obj;
} return new Object(o); //FIXME: Cast up when we know how.
obj = new Object(o); //FIXME: Cast up when we know how.
return obj;
} }
public Object(IntPtr o) public Object(IntPtr o)
@ -40,15 +33,8 @@ namespace GLib {
return _obj; return _obj;
} }
set { set {
IntPtr key = g_object_get_data (value, GOBJECTKEY); if ((Object)Objects[(int)value] != null) Objects.Remove((int)value);
if ((int)key != 0) Objects[(int)value] = this;
{
Object obj = (Object)Objects[(int)key];
if (obj != null) Objects.Remove((int)key);
}
key = new IntPtr(this.GetHashCode());
Objects[(int)key] = this;
g_object_set_data (value, GOBJECTKEY, key);
_obj = value; _obj = value;
} }
} }