Merge pull request #6 from bl8/floating-refs
Handle floating refs in InitiallyUnowned
This commit is contained in:
commit
9d7eec2eca
2 changed files with 37 additions and 29 deletions
|
@ -35,6 +35,43 @@ namespace GLib {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
private static extern void g_object_ref_sink (IntPtr raw);
|
||||||
|
|
||||||
|
protected override IntPtr Raw {
|
||||||
|
get {
|
||||||
|
return base.Raw;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
if (value != IntPtr.Zero)
|
||||||
|
g_object_ref_sink (value);
|
||||||
|
base.Raw = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern bool g_object_is_floating (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void g_object_force_floating (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void g_object_unref (IntPtr raw);
|
||||||
|
|
||||||
|
public bool IsFloating {
|
||||||
|
get {
|
||||||
|
return g_object_is_floating (Handle);
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
if (value == true) {
|
||||||
|
if (!IsFloating)
|
||||||
|
g_object_force_floating (Handle);
|
||||||
|
} else {
|
||||||
|
g_object_ref_sink (Handle);
|
||||||
|
g_object_unref (Handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -378,16 +378,11 @@ public void Path (out string path, out string path_reversed)
|
||||||
base.Dispose (disposing);
|
base.Dispose (disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
private static extern void g_object_ref_sink (IntPtr raw);
|
|
||||||
|
|
||||||
protected override IntPtr Raw {
|
protected override IntPtr Raw {
|
||||||
get {
|
get {
|
||||||
return base.Raw;
|
return base.Raw;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if (value != IntPtr.Zero)
|
|
||||||
g_object_ref_sink (value);
|
|
||||||
base.Raw = value;
|
base.Raw = value;
|
||||||
if (value != IntPtr.Zero)
|
if (value != IntPtr.Zero)
|
||||||
InternalDestroyed += NativeDestroyHandler;
|
InternalDestroyed += NativeDestroyHandler;
|
||||||
|
@ -404,27 +399,3 @@ public void Path (out string path, out string path_reversed)
|
||||||
gtk_widget_destroy (Handle);
|
gtk_widget_destroy (Handle);
|
||||||
InternalDestroyed -= NativeDestroyHandler;
|
InternalDestroyed -= NativeDestroyHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern bool g_object_is_floating (IntPtr raw);
|
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern void g_object_force_floating (IntPtr raw);
|
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern void g_object_unref (IntPtr raw);
|
|
||||||
|
|
||||||
public bool IsFloating {
|
|
||||||
get {
|
|
||||||
return g_object_is_floating (Handle);
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
if (value == true) {
|
|
||||||
if (!IsFloating)
|
|
||||||
g_object_force_floating (Handle);
|
|
||||||
} else {
|
|
||||||
g_object_ref_sink (Handle);
|
|
||||||
g_object_unref (Handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue