Skip to content

Commit

Permalink
Fix setter of GObject properties when using nulable types.
Browse files Browse the repository at this point in the history
  • Loading branch information
hugopl committed Nov 28, 2023
1 parent 4f05b8e commit 6799ffe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ecr/property.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<% if prop.type_info.array? -%>
# handle array
unsafe_value = value.to_a.map(&.to_unsafe).to_unsafe
<% elsif prop.type_info.object? -%>
unsafe_value = value.nil? ? Pointer(Void).null : value.to_unsafe
<% else -%>
unsafe_value = value
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion spec/properties_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe "GObject properties" do
subject.gobj.object_id.should eq(value.object_id)
value.ref_count.should eq(2)

subject.gobj = nil
subject.gobj = value.may_return_null(true)
value.ref_count.should eq(1)
subject.gobj.should eq(nil)
end
Expand Down

0 comments on commit 6799ffe

Please sign in to comment.