[Gtk-sharp-list] Agressive ref-couting.
Miguel de Icaza
miguel@ximian.com
11 Sep 2002 01:07:21 -0400
--=-mI+U58ZuRhv7RN/ttG3S
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hello guys,
The following patch makes mPhoto work again, when GC happens, we are
destroying objects that we did not ref previously.
Miguel.
--=-mI+U58ZuRhv7RN/ttG3S
Content-Disposition: attachment; filename=x
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=x; charset=ISO-8859-1
? autom4te.cache
? generated
? x
? api/generated-stamp
? parser/gapi_format_xml
? sample/a.cs
? sample/help.cs
? sample/image.cs
? sample/logo.png
? sample/x
Index: ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/ChangeLog,v
retrieving revision 1.214
diff -u -r1.214 ChangeLog
--- ChangeLog 8 Sep 2002 01:29:06 -0000 1.214
+++ ChangeLog 11 Sep 2002 05:08:10 -0000
@@ -1,3 +1,10 @@
+2002-09-11 Miguel de Icaza <miguel@ximian.com>
+
+ * glib/ObjectManager.cs: Ref objects that we are wrapping.=20
+
+ * glib/Object.cs (DisposeNative): Call GC.SuppressFinalize, and
+ set the obj to null.
+
2002-09-07 Rachel Hestilow <hestilow@ximian.com>
=20
* parser/gapi2xml.pl: Add support for "fake struct" opaque types.
Index: glib/Object.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/glib/Object.cs,v
retrieving revision 1.27
diff -u -r1.27 Object.cs
--- glib/Object.cs 4 Sep 2002 05:25:57 -0000 1.27
+++ glib/Object.cs 11 Sep 2002 05:08:10 -0000
@@ -55,15 +55,26 @@
=20
[DllImport("gobject-2.0")]
static extern void g_object_unref (IntPtr raw);
-
+ =09
protected virtual void DisposeNative ()
{
if (_obj =3D=3D IntPtr.Zero)
return;
=20
+ GC.SuppressFinalize (this);
g_object_unref (_obj);
+ _obj =3D IntPtr.Zero;
}
=20
+ [DllImport("gobject-2.0")]
+ static extern void g_object_ref (IntPtr raw);
+
+ // Called internally by the ObjectManager.
+ internal void Ref ()
+ {
+ g_object_ref (_obj);
+ }
+ =09
/// <summary>
/// GetObject Shared Method=20
/// </summary>
Index: glib/ObjectManager.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/gtk-sharp/glib/ObjectManager.cs,v
retrieving revision 1.5
diff -u -r1.5 ObjectManager.cs
--- glib/ObjectManager.cs 20 Aug 2002 19:56:17 -0000 1.5
+++ glib/ObjectManager.cs 11 Sep 2002 05:08:10 -0000
@@ -30,7 +30,10 @@
Type t =3D Type.GetType (mangled);
if (t =3D=3D null)
return null;
- return (GLib.Object) Activator.CreateInstance (t, new object[] {raw});
+
+ GLib.Object o =3D (GLib.Object) Activator.CreateInstance (t, new object=
[] {raw});
+ o.Ref ();
+ return o;
}
=20
public static void RegisterType (string native_name, string managed_name=
, string assembly)
--=-mI+U58ZuRhv7RN/ttG3S--