Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibGio#g_list_store_splice argument error #73

Open
BigBoyBarney opened this issue Dec 20, 2024 · 2 comments · May be fixed by hugopl/gi-crystal#167
Open

LibGio#g_list_store_splice argument error #73

BigBoyBarney opened this issue Dec 20, 2024 · 2 comments · May be fixed by hugopl/gi-crystal#167
Labels
bug Something isn't working

Comments

@BigBoyBarney
Copy link

BigBoyBarney commented Dec 20, 2024

Hi! Thanks for the bindings! 🥳

When trying to #splice an Enumerable of GObjects into a ListStore, i get the following error:

 275 | LibGio.g_list_store_splice(to_unsafe, position, n_removals, additions, n_additions)
                                                                   ^--------
Error: argument 'additions' of 'LibGio#g_list_store_splice' must be Pointer(LibGObject::Object), not Pointer(Pointer(Void))

Example code snippet:

list_store = Gio::ListStore.new(Gtk::Button.g_type)
one = Gtk::Button.new
two = Gtk::Button.new

items = [one, two]
list_store.splice(position: 0_u32, n_removals: 0_u32, additions: items)
@BigBoyBarney
Copy link
Author

In the generated bindings: gi-crystal/src/auto/gio-2.0/list_store.cr at line 271

- additions = additions.to_a.map(&.to_unsafe).to_unsafe
+ additions = additions.to_a.map(&.to_unsafe).to_unsafe.as(Pointer(LibGObject::Object))

I assume in the binding generator this is in src/generator/arg_strategy.cr but honestly, I have no idea what I'm doing 🤣

- generate_array_to_unsafe(io, arg_name, arg.type_info)
+ generate_array_to_unsafe(io, arg_name, arg.type_info).as(Pointer(LibGObject::Object))

I have no idea whether this breaks anything else, but it solves this issue.

@BigBoyBarney
Copy link
Author

This seems to be the case for all types using arg_strategy.

Gdk::Paintable#snapshot_symbolic similarly needs:

- colors = colors.to_a.map(&.to_unsafe).to_unsafe
+ colors = colors.to_a.map(&.to_unsafe).to_unsafe.as(Pointer(LibGdk::RGBA))

@hugopl hugopl added the bug Something isn't working label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants