Add method GetRawOwnedObject to Builder.
This method performs a GetRawObject, but also increases the refcount. This is (at least) needed in cases where you wish to have a class inherting a widget, and use a builder in the constructor : base (builder.GetRawObject("name")) Because no ref is taken the eventual freeing of the builder will cause the our object (this) to have a refcount 0. This is an issue since the freeing of our ToggleRef (which should happen later) performs an unref.
This commit is contained in:
parent
41d6f0bf28
commit
0daa985316
1 changed files with 10 additions and 0 deletions
|
@ -152,6 +152,16 @@ namespace Gtk {
|
||||||
return raw_ret;
|
return raw_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
delegate IntPtr d_g_object_ref(IntPtr raw);
|
||||||
|
static d_g_object_ref g_object_ref = FuncLoader.LoadFunction<d_g_object_ref>(FuncLoader.GetProcAddress(GLibrary.Load(Library.GObject), "g_object_ref"));
|
||||||
|
|
||||||
|
public IntPtr GetRawOwnedObject(string name) {
|
||||||
|
IntPtr raw_ret = GetRawObject (name);
|
||||||
|
g_object_ref (raw_ret);
|
||||||
|
return raw_ret;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder (System.IO.Stream s) : this (s, null)
|
public Builder (System.IO.Stream s) : this (s, null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue