diff --git a/ChangeLog b/ChangeLog index bf6a4e3f1..14c255c69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,81 @@ +2005-07-29 Dan Winship + + Automatic memory management for opaque types [#49565] + + * glib/Opaque.cs (Owned): new property saying whether or not gtk# + owns the memory. + (Opaque): Set Owned to true in the void ctor and false in the + IntPtr one. + (GetOpaque): add a new overload that can also create opaques, a la + GLib.Object.GetObject. + (Ref, Unref, Free): empty virtual methods to be overridden by + subclasses. + (set_Raw): Unref() and possibly Free() the old value, Ref() the + new one. + (~Opaque, Dispose): set Raw to IntPtr.Zero (triggering Free/Unref + if needed) + + * parser/gapi2xml.pl (addReturnElem): if the method is named Copy + and returns a pointer, set the "owned" attribute on the + return-type. + + * */*-api.raw: Regen + + * generator/HandleBase.cs (FromNative): Add new + FromNative/FromNativeReturn overloads that takes a "bool owned" + param. Implement the 1-arg FromNative and FromNativeReturn in + terms of that. + + * generator/ObjectBase.cs (FromNative): Implement HandleBase's new + overload. Use the two-arg version of GLib.Object.GetObject when + "owned" is true. + + * generator/OpaqueGen.cs (Generate): Pull out Ref, Unref, and + Free/Destroy/Dispose methods and handle them specially by + overriding Opaque.Ref, .Unref, and .Free appropriately. (If any + of the methods are marked deprecated, output a deprecated + do-nothing method as well, to save us from having to write all + those deprecated methods by hand.) + (FromNative): use GetOpaque, passing "owned". + + * generator/ReturnValue.cs (FromNative): if the value is a + HandleBase, pass Owned to its FromNative(). + + * generator/Parameters.cs (Owned): new property (for use on out + params) + (FromNative): Call FromNative() on the generatable, handling Owned + in the case of HandleBase. + + * generator/ManagedCallString.cs: + * generator/MethodBody.cs: + * generator/Signal.cs: use param.FromNative() rather than + param.Generatable.FromNative(), to get ownership right. + + * */*.metadata: Mark opaque ref/unref/free methods deprecated + (except where we were hiding them before). Add "owned" attributes + to return values and out params as needed. + + * pango/AttrIterator.custom (GetFont): work around a + memory-management oddity of the underlying method. + + * pango/AttrFontDesc.cs (AttrFontDesc): copy the passed-in + FontDescriptor, since the attribute will assume ownership of it. + + * gtk/TreeView.custom (GetPathAtPos): set the "owned" flag on the + returned TreePaths. + + * gtk/TargetList.custom: Remove refcounting stuff, which is + now handled automatically + + * gtk/NodeStore.cs (GetPath): clear the Owned flag on the created + TreePath so that the underlying structure doesn't get freed when + the function returns + + * gtkhtml/HTMLStream.custom (Destroy): hide this and then + reimplement it by hand to keep OpaqueGen from using it in + Dispose(), since calling it after an HTMLStream.Close() will + result in a crash. + 2005-08-01 Todd Berman * gtk/Gtk.metadata: Change the Gtk.Style.Paint* methods to use a diff --git a/gda/Gda.metadata b/gda/Gda.metadata index 2b91fce22..c3d084f19 100644 --- a/gda/Gda.metadata +++ b/gda/Gda.metadata @@ -14,9 +14,16 @@ 1 DataChanged 1 + 1 1 + 1 1 + 1 + 1 + 1 + 1 1 + 1 GetGdaType diff --git a/gda/gda-api.raw b/gda/gda-api.raw index 8005a623f..005053058 100644 --- a/gda/gda-api.raw +++ b/gda/gda-api.raw @@ -2167,7 +2167,7 @@ - + @@ -2510,7 +2510,7 @@ - + diff --git a/gdk/Gdk.metadata b/gdk/Gdk.metadata index a499580ee..b94ad32c5 100644 --- a/gdk/Gdk.metadata +++ b/gdk/Gdk.metadata @@ -6,6 +6,8 @@ gboolean ref 1 + 1 + 1 out out 1 @@ -165,6 +167,7 @@ 1 1 1 + 1 out 1 1 diff --git a/gdk/gdk-api-2.4.raw b/gdk/gdk-api-2.4.raw index a7abf2bf1..88d7ca81b 100644 --- a/gdk/gdk-api-2.4.raw +++ b/gdk/gdk-api-2.4.raw @@ -2668,7 +2668,7 @@ - + @@ -3098,7 +3098,7 @@ - + @@ -3663,7 +3663,7 @@ - + @@ -4534,7 +4534,7 @@ - + diff --git a/gdk/gdk-api-2.6.raw b/gdk/gdk-api-2.6.raw index 9246ac80b..3ba2a477e 100644 --- a/gdk/gdk-api-2.6.raw +++ b/gdk/gdk-api-2.6.raw @@ -2802,7 +2802,7 @@ - + @@ -3242,7 +3242,7 @@ - + @@ -3831,7 +3831,7 @@ - + @@ -4730,7 +4730,7 @@ - + diff --git a/generator/HandleBase.cs b/generator/HandleBase.cs index 31a2b7eed..08f7805a3 100644 --- a/generator/HandleBase.cs +++ b/generator/HandleBase.cs @@ -51,10 +51,27 @@ namespace GtkSharp.Generation { return "Handle"; } + public abstract string FromNative (string var, bool owned); + + public override string FromNative (string var) + { + return FromNative (var, false); + } + + public string FromNativeReturn (string var, bool owned) + { + return FromNative (var, owned); + } + + public override string FromNativeReturn (string var) + { + return FromNativeReturn (var, false); + } + public void WriteAccessors (StreamWriter sw, string indent, string var) { sw.WriteLine (indent + "get {"); - sw.WriteLine (indent + "\treturn " + FromNative (var) + ";"); + sw.WriteLine (indent + "\treturn " + FromNative (var, false) + ";"); sw.WriteLine (indent + "}"); sw.WriteLine (indent + "set {"); sw.WriteLine (indent + "\t" + var + " = " + CallByName ("value") + ";"); diff --git a/generator/ManagedCallString.cs b/generator/ManagedCallString.cs index 00dffe29f..e1a720936 100644 --- a/generator/ManagedCallString.cs +++ b/generator/ManagedCallString.cs @@ -40,7 +40,7 @@ namespace GtkSharp.Generation { IGeneratable igen = p.Generatable; if ((igen is StructGen || p.PassAs != "") && - (p.Name != igen.FromNative (p.Name))) + (p.Name != p.FromNative (p.Name))) this.special.Add (true); else this.special.Add (false); @@ -60,7 +60,7 @@ namespace GtkSharp.Generation { ret += indent + igen.QualifiedName + " my" + p.Name; if (igen is StructGen || p.PassAs == "ref") - ret += " = " + igen.FromNative (p.Name); + ret += " = " + p.FromNative (p.Name); ret += ";\n"; } @@ -76,9 +76,8 @@ namespace GtkSharp.Generation { for (int i = 0; i < parms.Count; i ++) { Parameter p = parms [i] as Parameter; - IGeneratable igen = p.Generatable; result [i] = p.PassAs == "" ? "" : p.PassAs + " "; - result [i] += ((bool)special[i]) ? "my" + p.Name : igen.FromNative (p.Name); + result [i] += ((bool)special[i]) ? "my" + p.Name : p.FromNative (p.Name); } return String.Join (", ", result); diff --git a/generator/MethodBody.cs b/generator/MethodBody.cs index d00ed1ce4..021dd3f1b 100644 --- a/generator/MethodBody.cs +++ b/generator/MethodBody.cs @@ -183,7 +183,7 @@ namespace GtkSharp.Generation { IGeneratable gen = p.Generatable; if (p.PassAs == "out" && p.CSType != p.MarshalType && !(gen is StructBase || gen is ByRefGen)) - sw.WriteLine(indent + "\t\t\t" + p.Name + " = " + gen.FromNative (p.Name + "_as_native") + ";"); + sw.WriteLine(indent + "\t\t\t" + p.Name + " = " + p.FromNative (p.Name + "_as_native") + ";"); else if (p.IsArray && gen is IManualMarshaler) { sw.WriteLine(indent + "\t\t\tfor (int i = 0; i < native_" + p.Name + ".Length; i++)"); sw.WriteLine(indent + "\t\t\t\t" + (gen as IManualMarshaler).ReleaseNative ("native_" + p.Name + "[i]") + ";"); diff --git a/generator/ObjectBase.cs b/generator/ObjectBase.cs index 2e5db5d3e..2f00e9b1f 100644 --- a/generator/ObjectBase.cs +++ b/generator/ObjectBase.cs @@ -28,9 +28,9 @@ namespace GtkSharp.Generation { protected ObjectBase (XmlElement ns, XmlElement elem) : base (ns, elem) {} - public override string FromNative(string var) + public override string FromNative (string var, bool owned) { - return "GLib.Object.GetObject(" + var + ") as " + QualifiedName; + return "GLib.Object.GetObject(" + var + (owned ? ", true" : "") + ") as " + QualifiedName; } } } diff --git a/generator/OpaqueGen.cs b/generator/OpaqueGen.cs index 2003144dd..44cc7dcf6 100644 --- a/generator/OpaqueGen.cs +++ b/generator/OpaqueGen.cs @@ -30,9 +30,9 @@ namespace GtkSharp.Generation { public OpaqueGen (XmlElement ns, XmlElement elem) : base (ns, elem) {} - public override string FromNative(string var) + public override string FromNative(string var, bool owned) { - return var + " == IntPtr.Zero ? null : new " + QualifiedName + "(" + var + ")"; + return var + " == IntPtr.Zero ? null : (" + QualifiedName + ") GLib.Opaque.GetOpaque (" + var + ", typeof (" + QualifiedName + "), " + (owned ? "true" : "false") + ")"; } private bool DisableRawCtor { @@ -58,6 +58,9 @@ namespace GtkSharp.Generation { SymbolTable table = SymbolTable.Table; + Method ref_, unref, dispose; + GetSpecialMethods (out ref_, out unref, out dispose); + sw.Write ("\tpublic class " + Name); string cs_parent = table.GetCSType(Elem.GetAttribute("parent")); if (cs_parent != "") @@ -70,6 +73,54 @@ namespace GtkSharp.Generation { GenFields (gen_info); GenMethods (gen_info, null, null); GenCtors (gen_info); + + if (ref_ != null) { + ref_.GenerateImport (sw); + sw.WriteLine ("\t\tprotected override void Ref (IntPtr raw)"); + sw.WriteLine ("\t\t{"); + sw.WriteLine ("\t\t\t" + ref_.CName + " (raw);"); + sw.WriteLine ("\t\t}"); + sw.WriteLine (); + + if (ref_.IsDeprecated) { + sw.WriteLine ("\t\t[Obsolete(\"" + QualifiedName + " is now refcounted automatically\")]"); + if (ref_.ReturnType == "void") + sw.WriteLine ("\t\tpublic void Ref () {}"); + else + sw.WriteLine ("\t\tpublic " + Name + " Ref () { return this; }"); + sw.WriteLine (); + } + } + if (unref != null) { + unref.GenerateImport (sw); + sw.WriteLine ("\t\tprotected override void Unref (IntPtr raw)"); + sw.WriteLine ("\t\t{"); + sw.WriteLine ("\t\t\t" + unref.CName + " (raw);"); + sw.WriteLine ("\t\t}"); + sw.WriteLine (); + + if (unref.IsDeprecated) { + sw.WriteLine ("\t\t[Obsolete(\"" + QualifiedName + " is now refcounted automatically\")]"); + sw.WriteLine ("\t\tpublic void Unref () {}"); + sw.WriteLine (); + } + } + + if (dispose != null) { + dispose.GenerateImport (sw); + sw.WriteLine ("\t\tprotected override void Free (IntPtr raw)"); + sw.WriteLine ("\t\t{"); + sw.WriteLine ("\t\t\t" + dispose.CName + " (raw);"); + sw.WriteLine ("\t\t}"); + sw.WriteLine (); + + if (dispose.IsDeprecated) { + sw.WriteLine ("\t\t[Obsolete(\"" + QualifiedName + " is now freed automatically\")]"); + sw.WriteLine ("\t\tpublic void " + dispose.Name + " () {}"); + sw.WriteLine (); + } + } + sw.WriteLine ("#endregion"); AppendCustom(sw, gen_info.CustomDir); @@ -82,6 +133,34 @@ namespace GtkSharp.Generation { Statistics.OpaqueCount++; } + void GetSpecialMethods (out Method ref_, out Method unref, out Method dispose) + { + ref_ = CheckSpecialMethod (GetMethod ("Ref")); + unref = CheckSpecialMethod (GetMethod ("Unref")); + + dispose = GetMethod ("Free"); + if (dispose == null) { + dispose = GetMethod ("Destroy"); + if (dispose == null) + dispose = GetMethod ("Dispose"); + } + dispose = CheckSpecialMethod (dispose); + } + + Method CheckSpecialMethod (Method method) + { + if (method == null) + return null; + if (method.ReturnType != "void" && + method.ReturnType != QualifiedName) + return null; + if (method.Signature.ToString () != "") + return null; + + methods.Remove (method.Name); + return method; + } + protected override void GenCtors (GenerationInfo gen_info) { if (!DisableRawCtor) { diff --git a/generator/Parameters.cs b/generator/Parameters.cs index a63b1332e..564b3678f 100644 --- a/generator/Parameters.cs +++ b/generator/Parameters.cs @@ -161,6 +161,12 @@ namespace GtkSharp.Generation { } } + public bool Owned { + get { + return elem.GetAttribute ("owned") == "true"; + } + } + public string PropertyName { get { return elem.GetAttribute("property_name"); @@ -206,7 +212,14 @@ namespace GtkSharp.Generation { call_parm = call_parm.Replace ("ref ", ""); return call_parm; + } + public string FromNative (string var) + { + if (Generatable is HandleBase) + return ((HandleBase)Generatable).FromNative (var, Owned); + else + return Generatable.FromNative (var); } public string StudlyName { diff --git a/generator/ReturnValue.cs b/generator/ReturnValue.cs index 26af3cc5c..37d971683 100644 --- a/generator/ReturnValue.cs +++ b/generator/ReturnValue.cs @@ -131,9 +131,10 @@ namespace GtkSharp.Generation { string type_str = "typeof (" + ElementType + ")"; string args = type_str + ", " + (Owned ? "true" : "false") + ", " + (ElementsOwned ? "true" : "false"); return String.Format ("({0}[]) GLib.Marshaller.ListToArray ({1}, {2})", ElementType, IGen.FromNativeReturn (var + ", " + args), type_str); - } else if (Owned) - var += ", true"; - return IGen.FromNativeReturn (var); + } else if (IGen is HandleBase) + return ((HandleBase)IGen).FromNative (var, Owned); + else + return IGen.FromNativeReturn (var); } public bool Validate () diff --git a/generator/Signal.cs b/generator/Signal.cs index 820e64843..4d4a716dd 100644 --- a/generator/Signal.cs +++ b/generator/Signal.cs @@ -213,10 +213,10 @@ namespace GtkSharp.Generation { sw.WriteLine("\t\t\tif (arg{0} == IntPtr.Zero)", idx); sw.WriteLine("\t\t\t\targs.Args[{0}] = null;", idx - 1); sw.WriteLine("\t\t\telse {"); - sw.WriteLine("\t\t\t\targs.Args[" + (idx - 1) + "] = " + igen.FromNative ("arg" + idx) + ";"); + sw.WriteLine("\t\t\t\targs.Args[" + (idx - 1) + "] = " + p.FromNative ("arg" + idx) + ";"); sw.WriteLine("\t\t\t}"); } else - sw.WriteLine("\t\t\targs.Args[" + (idx - 1) + "] = " + igen.FromNative ("arg" + idx) + ";"); + sw.WriteLine("\t\t\targs.Args[" + (idx - 1) + "] = " + p.FromNative ("arg" + idx) + ";"); } if (p.PassAs != "") finish += "\t\t\targ" + idx + " = " + igen.ToNativeReturn ("((" + p.CSType + ")args.Args[" + (idx - 1) + "])") + ";\n"; @@ -316,7 +316,7 @@ namespace GtkSharp.Generation { sw.WriteLine ("\t\t\tIntPtr " + p.Name + "_ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (" + p.MarshalType + ")));"); sw.WriteLine ("\t\t\tvals [" + i + "] = new GLib.Value (" + p.Name + "_ptr);"); - cleanup += "\t\t\t" + p.Name + " = " + p.Generatable.FromNative ("(" + p.MarshalType + ") Marshal.PtrToStructure (" + p.Name + "_ptr, typeof (" + p.MarshalType + "))") + ";\n"; + cleanup += "\t\t\t" + p.Name + " = " + p.FromNative ("(" + p.MarshalType + ") Marshal.PtrToStructure (" + p.Name + "_ptr, typeof (" + p.MarshalType + "))") + ";\n"; cleanup += "\t\t\tMarshal.FreeHGlobal (" + p.Name + "_ptr);\n"; } } else if (p.IsLength && parms [i - 1].IsString) diff --git a/glib/Opaque.cs b/glib/Opaque.cs index d0510909c..f75ff8ee2 100644 --- a/glib/Opaque.cs +++ b/glib/Opaque.cs @@ -31,25 +31,53 @@ namespace GLib { using System.ComponentModel; using System.Runtime.InteropServices; - public class Opaque : IWrapper { + public class Opaque : IWrapper, IDisposable { IntPtr _obj; + bool owned; + + // We don't have to do as much work here as GLib.Object.GetObject + // does; users can't subclass opaque types, so nothing bad will happen + // if we accidentally end up creating two wrappers for the same object. + static Hashtable Opaques = new Hashtable(); - public static Opaque GetOpaque(IntPtr o) + public static Opaque GetOpaque (IntPtr o) { - WeakReference reference = (WeakReference) Opaques[(int)o]; - if (reference == null || !reference.IsAlive) + WeakReference reference = (WeakReference) Opaques[o]; + if (reference == null) return null; + if (!reference.IsAlive) { + Opaques.Remove (o); + return null; + } return (Opaque) reference.Target; } - public Opaque () {} + public static Opaque GetOpaque (IntPtr o, Type type, bool owned) + { + Opaque opaque = GetOpaque (o); + if (opaque != null) { + if (owned) + opaque.owned = true; + return opaque; + } + + opaque = (Opaque)Activator.CreateInstance (type, new object[] { o }); + opaque.owned = owned; + return opaque; + } + + public Opaque () + { + owned = true; + } public Opaque (IntPtr raw) { Raw = raw; + owned = false; } protected IntPtr Raw { @@ -57,17 +85,53 @@ namespace GLib { return _obj; } set { - Opaques [value] = new WeakReference (this); + if (_obj != IntPtr.Zero) { + Opaques.Remove (_obj); + Unref (_obj); + if (owned) + Free (_obj); + } _obj = value; + if (_obj != IntPtr.Zero) { + Ref (_obj); + Opaques [_obj] = new WeakReference (this); + } } } + ~Opaque () + { + Dispose (); + } + + public virtual void Dispose () + { + Raw = IntPtr.Zero; + GC.SuppressFinalize (this); + } + + // These take an IntPtr arg so we don't get conflicts if we need + // to have an "[Obsolete] public void Ref ()" + + protected virtual void Ref (IntPtr raw) {} + protected virtual void Unref (IntPtr raw) {} + protected virtual void Free (IntPtr raw) {} + public IntPtr Handle { get { return _obj; } } + public bool Owned { + get { + return owned; + } + set { + owned = value; + } + } + public override bool Equals (object o) { if (!(o is Opaque)) diff --git a/gnome/Gnome.metadata b/gnome/Gnome.metadata index 2b9b71d70..d698db332 100644 --- a/gnome/Gnome.metadata +++ b/gnome/Gnome.metadata @@ -18,7 +18,11 @@ 1 1 1 + 1 + 1 const-gchar* + 1 + 1 1 public public @@ -151,9 +155,12 @@ LineTo LineToMoving MoveTo + 1 GnomeCanvasPathDef* true true + 1 1 const-gchar* + 1 diff --git a/gnomevfs/Gnomevfs.metadata b/gnomevfs/Gnomevfs.metadata index b10dbe8f5..0e2f6d783 100644 --- a/gnomevfs/Gnomevfs.metadata +++ b/gnomevfs/Gnomevfs.metadata @@ -76,6 +76,7 @@ 1 1 1 + 1 1 1 @@ -118,8 +119,6 @@ 1 1 1 - 1 - 1 1 1 1 diff --git a/gnomevfs/gnome-vfs-api.raw b/gnomevfs/gnome-vfs-api.raw index 33e771a6f..2eee8337d 100644 --- a/gnomevfs/gnome-vfs-api.raw +++ b/gnomevfs/gnome-vfs-api.raw @@ -985,7 +985,7 @@ - + diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index 0fb404e2b..053cd17b4 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -10,13 +10,18 @@ 1 1 1 + 1 1 + 1 + 1 + 1 1 public public public public public + 1 1 1 1 @@ -32,6 +37,9 @@ 1 1 1 + 1 + 1 + true 1 1 1 @@ -85,6 +93,7 @@ 1 out out + true 1 1 1 @@ -129,6 +138,7 @@ 1 out out + true ref out ref @@ -211,6 +221,7 @@ EmitToggled 1 1 + true out 1 out @@ -299,8 +310,13 @@ 1 1 1 + true 1 ActivateItem + true + GtkTreePath* + true + true AllSelected 1 AllUnselected @@ -494,10 +510,14 @@ TooltipSet out out + true + true 1 model out out + true + true out 1 call @@ -526,9 +546,12 @@ 1 out out + true out + true out out + true out out 1 @@ -636,12 +659,9 @@ 1 GtkTargetFlags 1 - 1 1 1 n_targets - 1 - 1 PangoUnderline 1 1 diff --git a/gtk/NodeStore.cs b/gtk/NodeStore.cs index 8e0c52cf8..35e2d5beb 100644 --- a/gtk/NodeStore.cs +++ b/gtk/NodeStore.cs @@ -451,6 +451,8 @@ namespace Gtk { idx = Nodes.IndexOf (node); if (idx < 0) throw new Exception ("Node not found in Nodes list"); path.PrependIndex (idx); + + path.Owned = false; return path; } diff --git a/gtk/TargetList.custom b/gtk/TargetList.custom index a22f9218a..ed5ae45e6 100644 --- a/gtk/TargetList.custom +++ b/gtk/TargetList.custom @@ -16,20 +16,6 @@ // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_target_list_ref(IntPtr raw); - - public TargetList(IntPtr raw) : base(raw) { - gtk_target_list_ref(raw); - } - - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_target_list_unref(IntPtr raw); - - ~TargetList() { - gtk_target_list_unref(Handle); - } - [DllImport("libgtk-win32-2.0-0.dll")] static extern IntPtr gtk_target_list_new(Gtk.TargetEntry[] targets, uint n_targets); diff --git a/gtk/TreeView.custom b/gtk/TreeView.custom index 5c2af394e..9323f6adb 100644 --- a/gtk/TreeView.custom +++ b/gtk/TreeView.custom @@ -82,6 +82,7 @@ if (raw_ret) { column = (Gtk.TreeViewColumn) GLib.Object.GetObject (columnHandle, false); path = new TreePath (pathHandle); + path.Owned = true; } else { path = null; column = null; @@ -96,9 +97,10 @@ IntPtr pathHandle; IntPtr columnHandle; bool raw_ret = gtk_tree_view_get_path_at_pos_intptr (Handle, x, y, out pathHandle, out columnHandle, IntPtr.Zero, IntPtr.Zero); - if (raw_ret) + if (raw_ret) { path = new TreePath (pathHandle); - else + path.Owned = true; + } else path = null; return raw_ret; @@ -111,6 +113,7 @@ bool raw_ret = gtk_tree_view_get_path_at_pos_intptr (Handle, x, y, out pathHandle, out columnHandle, IntPtr.Zero, IntPtr.Zero); if (raw_ret) { path = new TreePath (pathHandle); + path.Owned = true; column = (Gtk.TreeViewColumn) GLib.Object.GetObject (columnHandle, false); } else { path = null; diff --git a/gtk/gtk-api-2.4.raw b/gtk/gtk-api-2.4.raw index f48f3841c..fee3d3e5d 100644 --- a/gtk/gtk-api-2.4.raw +++ b/gtk/gtk-api-2.4.raw @@ -8488,7 +8488,7 @@ - + @@ -9602,7 +9602,7 @@ - + @@ -14890,7 +14890,7 @@ - + @@ -14932,7 +14932,7 @@ - + @@ -14986,7 +14986,7 @@ - + @@ -15024,7 +15024,7 @@ - + @@ -15227,7 +15227,7 @@ - + @@ -15252,7 +15252,7 @@ - + @@ -15303,7 +15303,7 @@ - + @@ -15431,7 +15431,7 @@ - + @@ -15572,7 +15572,7 @@ - + @@ -15904,7 +15904,7 @@ - + @@ -15927,7 +15927,7 @@ - + @@ -15990,7 +15990,7 @@ - + diff --git a/gtk/gtk-api-2.6.raw b/gtk/gtk-api-2.6.raw index 38658f71d..6f9cb7222 100644 --- a/gtk/gtk-api-2.6.raw +++ b/gtk/gtk-api-2.6.raw @@ -9356,7 +9356,7 @@ - + @@ -10470,7 +10470,7 @@ - + @@ -15865,7 +15865,7 @@ - + @@ -15907,7 +15907,7 @@ - + @@ -15961,7 +15961,7 @@ - + @@ -15999,7 +15999,7 @@ - + @@ -16208,7 +16208,7 @@ - + @@ -16233,7 +16233,7 @@ - + @@ -16308,7 +16308,7 @@ - + @@ -16455,7 +16455,7 @@ - + @@ -16596,7 +16596,7 @@ - + @@ -16928,7 +16928,7 @@ - + @@ -16951,7 +16951,7 @@ - + @@ -17014,7 +17014,7 @@ - + diff --git a/gtkhtml/Gtk.metadata b/gtkhtml/Gtk.metadata index 81979b5a7..8df5a8954 100644 --- a/gtkhtml/Gtk.metadata +++ b/gtkhtml/Gtk.metadata @@ -7,6 +7,7 @@ Begin Begin 1 + 1 const-guchar* 1 diff --git a/gtkhtml/HTMLStream.custom b/gtkhtml/HTMLStream.custom index cfd4f88d5..e4b35e819 100644 --- a/gtkhtml/HTMLStream.custom +++ b/gtkhtml/HTMLStream.custom @@ -30,3 +30,14 @@ public void Write (string buffer) gtk_html_stream_write (Handle, bytes, new UIntPtr ((ulong)bytes.Length)); } + +// We hide this method and then reimplement it by hand to keep OpaqueGen from using +// it in Dispose(), since calling it after a Close() will result in a crash. + +[DllImport("gtkhtml-3.0")] +static extern void gtk_html_stream_destroy (IntPtr stream); + +public void Destroy () +{ + gtk_html_stream_destroy (Handle); +} diff --git a/pango/AttrFontDesc.cs b/pango/AttrFontDesc.cs index 3d77f2fb3..3a60b1c50 100644 --- a/pango/AttrFontDesc.cs +++ b/pango/AttrFontDesc.cs @@ -26,7 +26,10 @@ namespace Pango { [DllImport("libpango-1.0-0.dll")] static extern IntPtr pango_attr_font_desc_new (IntPtr font_desc); - public AttrFontDesc (Pango.FontDescription font_desc) : this (pango_attr_font_desc_new (font_desc.Handle)) {} + [DllImport("libpango-1.0-0.dll")] + static extern IntPtr pango_font_description_copy(IntPtr raw); + + public AttrFontDesc (Pango.FontDescription font_desc) : this (pango_attr_font_desc_new (pango_font_description_copy (font_desc.Handle))) {} internal AttrFontDesc (IntPtr raw) : base (raw) {} diff --git a/pango/AttrIterator.custom b/pango/AttrIterator.custom index 262ea4d54..8e4b8af31 100644 --- a/pango/AttrIterator.custom +++ b/pango/AttrIterator.custom @@ -29,6 +29,7 @@ desc = new FontDescription (); IntPtr language_handle, list_handle; pango_attr_iterator_get_font (Handle, desc.Handle, out language_handle, out list_handle); + desc.Family = desc.Family; // change static string to allocated one language = language_handle == IntPtr.Zero ? null : new Language (language_handle); if (list_handle == IntPtr.Zero) { extra_attrs = new Pango.Attribute [0]; diff --git a/pango/Pango.metadata b/pango/Pango.metadata index 1df68fbd4..02da54201 100644 --- a/pango/Pango.metadata +++ b/pango/Pango.metadata @@ -1,7 +1,17 @@ call + true + 1 + 1 + true + 1 + true + 1 + 1 + 1 1 + 1 1 1 1 @@ -14,18 +24,22 @@ 1 ref 1 + true 1 + true 1 1 call 1 out out + true 1 1 out out out + true out 1 1 @@ -36,13 +50,16 @@ 1 1 1 + 1 1 1 1 1 1 1 + 1 1 + 1 1 1 public @@ -51,6 +68,8 @@ ref ref 1 + 1 + 1 1 1 diff --git a/pango/pango-api-2.4.raw b/pango/pango-api-2.4.raw index 681b91040..5b15007dc 100644 --- a/pango/pango-api-2.4.raw +++ b/pango/pango-api-2.4.raw @@ -396,7 +396,7 @@ - + @@ -669,7 +669,7 @@ - + @@ -719,7 +719,7 @@ - + @@ -782,7 +782,7 @@ - + @@ -799,7 +799,7 @@ - + @@ -816,7 +816,7 @@ - + @@ -870,7 +870,7 @@ - + @@ -1045,7 +1045,7 @@ - + @@ -1120,7 +1120,7 @@ - + @@ -1333,7 +1333,7 @@ - + diff --git a/pango/pango-api-2.6.raw b/pango/pango-api-2.6.raw index d36fba112..1d21c4259 100644 --- a/pango/pango-api-2.6.raw +++ b/pango/pango-api-2.6.raw @@ -430,7 +430,7 @@ - + @@ -913,7 +913,7 @@ - + @@ -963,7 +963,7 @@ - + @@ -1053,7 +1053,7 @@ - + @@ -1070,7 +1070,7 @@ - + @@ -1087,7 +1087,7 @@ - + @@ -1141,7 +1141,7 @@ - + @@ -1348,7 +1348,7 @@ - + @@ -1423,7 +1423,7 @@ - + @@ -1623,7 +1623,7 @@ - + @@ -1682,7 +1682,7 @@ - + diff --git a/parser/gapi2xml.pl b/parser/gapi2xml.pl index 1bbe743f2..242bc2209 100755 --- a/parser/gapi2xml.pl +++ b/parser/gapi2xml.pl @@ -836,6 +836,9 @@ sub addReturnElem my $ret_elem = $doc->createElement('return-type'); $parent->appendChild($ret_elem); $ret_elem->setAttribute('type', $ret); + if ($parent->getAttribute('name') eq "Copy" && $ret =~ /\*$/) { + $ret_elem->setAttribute('owned', 'true'); + } return $ret_elem; } diff --git a/rsvg/Rsvg.metadata b/rsvg/Rsvg.metadata index d4bd572e6..d893cd434 100644 --- a/rsvg/Rsvg.metadata +++ b/rsvg/Rsvg.metadata @@ -1,5 +1,9 @@ 1 + 1 + 1 1 + 1 + 1