[Gtk-sharp-list] Agressive ref-couting.
Miguel de Icaza
miguel@ximian.com
11 Sep 2002 22:24:39 -0400
Hello!
> > The following patch makes mPhoto work again, when GC happens, we are
> > destroying objects that we did not ref previously.
>
> I'm not sure this is the solution. We shouldn't need to ref every
> object, because we should own the vast majority of handles that are
> returned by native methods. Is this a situation where you are using
> methods with "const" returns in the native library?
The problem happens with GCs and Styles:
static Gdk.GC EnsureGC (IntPtr raw) {
if (raw == IntPtr.Zero)
return null;
Gdk.GC ret = (Gdk.GC) GLib.Object.GetObject (raw);
if (ret == null)
ret = new Gdk.GC (raw);
return ret;
}
[DllImport("gtksharpglue")]
static extern IntPtr gtksharp_gtk_style_get_white_gc (IntPtr style);
public Gdk.GC WhiteGC {
get { return EnsureGC (gtksharp_gtk_style_get_white_gc(Handle));
}
The problem is that we are wrapping an object which is owned somewhere
else.
Miguel