-
Notifications
You must be signed in to change notification settings - Fork 466
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
Comments
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
init
assumes that only OS errors are encountered during initialization, but this is not the case since the underlyingFT_Init_FreeType
has other error conditions. Instead,init
should get the error fromSDL_GetError
as documented here (TTF_GetError
is#define
d asSDL_GetError
).To retain backwards compatibility with the current error type, it may be necessary to wrap the error in an Error with
ErrorKind::Other
.The text was updated successfully, but these errors were encountered: