2006-03-27 Mike Kestner <mkestner@novell.com>
* glib/ListBase.cs : deal with ownership of Opaque elements. * glib/Marshaller.cs : add a hack to deal with Opaque ownership in ListToArray marshaling. svn path=/trunk/gtk-sharp/; revision=58609
This commit is contained in:
parent
4a251355f3
commit
16fef6601b
3 changed files with 16 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2006-03-27 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* glib/ListBase.cs : deal with ownership of Opaque elements.
|
||||
* glib/Marshaller.cs : add a hack to deal with Opaque ownership in
|
||||
ListToArray marshaling.
|
||||
|
||||
2006-02-28 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* bootstrap-2.* : update for 2.x.2 releases.
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace GLib {
|
|||
private IntPtr list_ptr = IntPtr.Zero;
|
||||
private int length = -1;
|
||||
private bool managed = false;
|
||||
private bool elements_owned = false;
|
||||
internal bool elements_owned = false;
|
||||
protected System.Type element_type = null;
|
||||
|
||||
abstract internal IntPtr NthData (uint index);
|
||||
|
@ -134,6 +134,8 @@ namespace GLib {
|
|||
ret = data;
|
||||
else if (element_type.IsSubclassOf (typeof (GLib.Object)))
|
||||
ret = GLib.Object.GetObject (data, false);
|
||||
else if (element_type.IsSubclassOf (typeof (GLib.Opaque)))
|
||||
ret = GLib.Opaque.GetOpaque (data, element_type, elements_owned);
|
||||
else if (element_type == typeof (int))
|
||||
ret = (int) data;
|
||||
else if (element_type.IsValueType)
|
||||
|
@ -159,7 +161,9 @@ namespace GLib {
|
|||
for (uint i = 0; i < Count; i++)
|
||||
if (typeof (GLib.Object).IsAssignableFrom (element_type))
|
||||
g_object_unref (NthData (i));
|
||||
else
|
||||
else if (typeof (GLib.Opaque).IsAssignableFrom (element_type))
|
||||
GLib.Opaque.GetOpaque (NthData (i), element_type, true).Dispose ();
|
||||
else
|
||||
g_free (NthData (i));
|
||||
|
||||
if (managed)
|
||||
|
|
|
@ -286,6 +286,10 @@ namespace GLib {
|
|||
Array result = Array.CreateInstance (type, list.Count);
|
||||
if (list.Count > 0)
|
||||
list.CopyTo (result, 0);
|
||||
|
||||
if (type.IsSubclassOf (typeof (GLib.Opaque)))
|
||||
list.elements_owned = false;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue