Closed hugopl closed 4 years ago
Yeah, the typelib is just:
+ get_scheme (function, GtkSource)
* method = true
* throws = false
* skip_return = false
* may_return_null = false
* caller_owns = NOTHING
* self_arg_ownership = NOTHING
* return_type
+ <no name> (type, GtkSource)
* tag = INTERFACE
* pointer = true
* interface
+ StyleScheme (object, GtkSource)
So may_return_null = false
. We could in theory ignore this flag and always assume it can return a null pointer, but I found it better to just maintain manual overrides for these cases (and perhaps try to report it upstream).
Funnily enough GIRepository itself has the same issue in a couple of places, hence https://github.com/jhass/crystal-gobject/blob/8d87bb7b0d87534b2ce78c3add558bd554bf6fbe/src/g_i_repository/repository.cr#L38-L42
Though maybe we can improve the error message by asserting a non null pointer, potentially even suggesting to add a manual override. What do you think?
Alright, I implemented the above idea :)
Yes, IMO assert the null pointer is better, since the bug is on C library in this case, not on Crystal bindings.
Issue filled upstream https://gitlab.gnome.org/GNOME/gtksourceview/-/issues/133
Not sure if this is caused by wrong GIR annotations on GtkSourceView [1], but the generated bindings for
GtkSource::StyleSchemeManager#scheme
is not returingnil
when the C method returns a null pointer.So the following code crash:
Backtrace
[1] https://developer.gnome.org/gtksourceview/stable/GtkSourceStyleSchemeManager.html#gtk-source-style-scheme-manager-get-scheme