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

sdl2::ttf::init incorrectly incorrectly uses the last OS error. #1347

Open
sprocklem opened this issue Nov 4, 2023 · 0 comments
Open

sdl2::ttf::init incorrectly incorrectly uses the last OS error. #1347

sprocklem opened this issue Nov 4, 2023 · 0 comments

Comments

@sprocklem
Copy link

init assumes that only OS errors are encountered during initialization, but this is not the case since the underlying FT_Init_FreeType has other error conditions. Instead, init should get the error from SDL_GetError as documented here (TTF_GetError is #defined as SDL_GetError).

To retain backwards compatibility with the current error type, it may be necessary to wrap the error in an Error with ErrorKind::Other.

sprocklem pushed a commit to sprocklem/rust-sdl2 that referenced this issue Nov 4, 2023
Previously, the code use the last OS error. However, not all errors
returned by `TTF_Init` are OS errors, and the expected behaviour is that
the caller instead use `SDL_GetError` when an error is encountered.

To limit breakage for existing application the error is still returned
as an `io::Error`, albeit one with `io::ErrorKind::Other`. It is
worth noting that this does lead to an observable difference in
behaviour for callers – the error has a different kind – although any
code that is inspecting this was already relying on an unreliable source
of data.

This fixes issue Rust-SDL2#1347.
sprocklem pushed a commit to sprocklem/rust-sdl2 that referenced this issue Nov 4, 2023
Previously, the code use the last OS error. However, not all errors
returned by `TTF_Init` are OS errors, and the expected behaviour is that
the caller instead use `SDL_GetError` when an error is encountered.

To limit breakage for existing application the error is still returned
as an `io::Error`, albeit one with `io::ErrorKind::Other`. It is
worth noting that this does lead to an observable difference in
behaviour for callers – the error has a different kind – although any
code that is inspecting this was already relying on an unreliable source
of data.

This fixes issue Rust-SDL2#1347.
sprocklem pushed a commit to sprocklem/rust-sdl2 that referenced this issue Nov 4, 2023
Previously, the code use the last OS error. However, not all errors
returned by `TTF_Init` are OS errors, and the expected behaviour is that
the caller instead use `SDL_GetError` when an error is encountered.

To limit breakage for existing application the error is still returned
as an `io::Error`, albeit one with `io::ErrorKind::Other`. It is
worth noting that this does lead to an observable difference in
behaviour for callers – the error has a different kind – although any
code that is inspecting this was already relying on an unreliable source
of data.

This fixes issue Rust-SDL2#1347.
sprocklem pushed a commit to sprocklem/rust-sdl2 that referenced this issue Nov 4, 2023
Previously, the code use the last OS error. However, not all errors
returned by `TTF_Init` are OS errors, and the expected behaviour is that
the caller instead use `SDL_GetError` when an error is encountered.

To limit breakage for existing application the error is still returned
as an `io::Error`, albeit one with `io::ErrorKind::Other`. It is
worth noting that this does lead to an observable difference in
behaviour for callers – the error has a different kind – although any
code that is inspecting this was already relying on an unreliable source
of data.

This fixes issue Rust-SDL2#1347.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant