2007-07-19 Mike Kestner <mkestner@novell.com>

* generator/OpaqueGen.cs : override the new Copy vm if a Copy method
	exists for the type.
	* glib/Opaque.cs : add a virtual method to allow subclasses with
	Copy methods to override.  Use the method in GetOpaque for unowned
	instantiations to try to obtain an owned instance. [Fixes #82037]

svn path=/trunk/gtk-sharp/; revision=82293
This commit is contained in:
Mike Kestner 2007-07-19 15:35:28 +00:00
parent 0951a97f5a
commit a06235f02f
3 changed files with 25 additions and 1 deletions

View file

@ -1,3 +1,11 @@
2007-07-19 Mike Kestner <mkestner@novell.com>
* generator/OpaqueGen.cs : override the new Copy vm if a Copy method
exists for the type.
* glib/Opaque.cs : add a virtual method to allow subclasses with
Copy methods to override. Use the method in GetOpaque for unowned
instantiations to try to obtain an owned instance. [Fixes #82037]
2007-07-18 Mike Kestner <mkestner@novell.com>
* gdk/EventExpose.cs : return a pointer from the get_area glue

View file

@ -129,6 +129,16 @@ namespace GtkSharp.Generation {
}
}
Method copy = Methods ["Copy"] as Method;
if (copy != null) {
sw.WriteLine ("\t\tprotected override GLib.Opaque Copy (IntPtr raw)");
sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\tGLib.Opaque result = new " + QualifiedName + " (" + copy.CName + " (raw));");
sw.WriteLine ("\t\t\tresult.Owned = true;");
sw.WriteLine ("\t\t\treturn result;");
sw.WriteLine ("\t\t}");
sw.WriteLine ();
}
sw.WriteLine ("#endregion");
AppendCustom(sw, gen_info.CustomDir);

View file

@ -51,7 +51,9 @@ namespace GLib {
opaque.Unref (o);
}
opaque.owned = true;
}
} else
opaque = opaque.Copy (o);
return opaque;
}
@ -100,6 +102,10 @@ namespace GLib {
protected virtual void Ref (IntPtr raw) {}
protected virtual void Unref (IntPtr raw) {}
protected virtual void Free (IntPtr raw) {}
protected virtual Opaque Copy (IntPtr raw)
{
return this;
}
public IntPtr Handle {
get {