Skip to content

Commit

Permalink
Merge pull request #1014 from gircore/properties
Browse files Browse the repository at this point in the history
Properties
  • Loading branch information
badcel authored Jan 29, 2024
2 parents 3f83c15 + 3e9567b commit 9a7cfa3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Libs/GObject-2.0/Public/Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ public T Get(K obj)
if (obj is not Object o)
throw new Exception($"Can't get property {ManagedName} for object of type {typeof(K).Name} as it is not derived from {nameof(Object)}.");

var valueHandle = Internal.ValueManagedHandle.Create();
Internal.Object.GetProperty(o.Handle, GLib.Internal.NonNullableUtf8StringOwnedHandle.Create(UnmanagedName), valueHandle);
using var value = new Value();
o.GetProperty(UnmanagedName, value);

return new Value(valueHandle).Extract<T>();
return value.Extract<T>();
}

/// <summary>
Expand All @@ -57,7 +57,8 @@ public void Set(K obj, T value)
var type = GetPropertyType(o.Handle);
using var gvalue = new Value(type);
gvalue.Set(value);
Internal.Object.SetProperty(o.Handle, GLib.Internal.NonNullableUtf8StringOwnedHandle.Create(UnmanagedName), gvalue.Handle);

o.SetProperty(UnmanagedName, gvalue);
}

private Type GetPropertyType(IntPtr handle)
Expand Down

0 comments on commit 9a7cfa3

Please sign in to comment.