Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

[BUG] Wrong return turn (u32 vs gint) for GtkNotebook append_page #785

Open
dvogel opened this issue Oct 24, 2022 · 3 comments
Open

[BUG] Wrong return turn (u32 vs gint) for GtkNotebook append_page #785

dvogel opened this issue Oct 24, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@dvogel
Copy link

dvogel commented Oct 24, 2022

Bug description

Please provide a code sample as small as possible which reproduces the bug.

Upstream gtk_notebook_append_page returns a gint. In gtk3-rs NotebookExtManual.append_page returns a u32. The documentation says the function will return -1 on error, which is impossible in the rust code.

@dvogel dvogel added the bug Something isn't working label Oct 24, 2022
@GuillaumeGomez
Copy link
Member

There is an assert in the code to ensure the returned value is >= 0. It'll panic if it isn't the case so it can never return something less than 0.

@GuillaumeGomez
Copy link
Member

It might a bit problematic because it can actually return -1 with our code since we accept nullable arguments and the function returns -1 if an argument is nullable. So either we don't allow the arguments to be nullable, or we return Option<u32>.

@sdroege
Copy link
Member

sdroege commented Oct 28, 2022

If the function doesn't allow NULL then we should not allow passing None.

But I think this can actually fail in other ways, can't it? It calls into a virtual method somewhere and it looks like at least the default implementation of that can also fail in other reasons (if the page already was added to another notebook maybe?).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants