gtk-rs-core icon indicating copy to clipboard operation
gtk-rs-core copied to clipboard

[BUG] Wrong signature for `gio::content_type_guess`

Open Schmiddiii opened this issue 1 year ago • 4 comments

Bug description

The signature of gio::content_type_guess has the type of data as &[u8]. The same documentation, and also the gio documentation mention that data can be None. So a better signature would set data to Option<&[u8]> or similar. Note that the current signature can lead to wrong results if one wants the content type to be guessed only based on the filetype, this is not possible based on the current signature.

This change would be breaking.

Schmiddiii avatar Dec 24 '23 15:12 Schmiddiii

It looks like currently all array-like nullable parameters are not optional. Passing &[] might or might not do what you want, but this should probably be fixed and be made more explicit. It's also not guaranteed that empty / NULL give the same behaviour.

This would need a change in the code generator.

sdroege avatar Dec 24 '23 15:12 sdroege

Pretty sure None and &[] are not the same for this function, passing &[] is interpreted as "empty file" and leading to application/x-empty (at least in one case I had, it worked for one other case. Not sure what the exact rules are).

Schmiddiii avatar Dec 24 '23 15:12 Schmiddiii

Related: https://github.com/gtk-rs/gir/issues/1133

euclio avatar Dec 24 '23 15:12 euclio