2003-04-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>

* glib/Object.cs:
	(GetObject): check that the target of the WeakReference is still there. Otherwise,
	create a new wrapper for the IntPtr.

	This fixes the random nullrefs when running nunit-gtk.

svn path=/trunk/gtk-sharp/; revision=13450
This commit is contained in:
Gonzalo Paniagua Javier 2003-04-09 17:50:51 +00:00
parent 0d5cea38d4
commit 1840bd7ef1
2 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2003-04-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* glib/Object.cs:
(GetObject): check that the target of the WeakReference is still there. Otherwise,
create a new wrapper for the IntPtr.
This fixes the random nullrefs when running nunit-gtk.
2003-04-03 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* generator/CallbackGen.cs: the new generated wrappers have:

View File

@ -163,8 +163,15 @@ namespace GLib {
public static Object GetObject(IntPtr o)
{
WeakReference obj = Objects[o] as WeakReference;
if (obj != null)
return obj.Target as GLib.Object;
if (obj != null) {
// If the target object has not been collected, use it...
if (obj.IsAlive)
return obj.Target as GLib.Object;
// ... otherwise we create a new wrapper around the IntPtr.
Objects [o] = null;
}
return GtkSharp.ObjectManager.CreateObject(o);
}