-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Canvas::fill_rect does not work at all #44
Comments
Can reproduce on Windows using 483fde4 and build-from-source replacing the implementation with the following fixes the issue but I am not sure what is actually wrong with the current implementation #[doc(alias = "SDL_RenderFillRect")]
pub fn fill_rect<R: Into<Option<FRect>>>(&mut self, rect: R) -> Result<(), String> {
let result= if let Some(rect) = rect.into() {
unsafe {
sys::render::SDL_RenderFillRect(
self.context.raw,
&rect.to_ll(),
)
}
} else {
unsafe {
sys::render::SDL_RenderFillRect(
self.context.raw,
ptr::null(),
)
}
};
if !result {
Err(get_error())
} else {
Ok(())
}
} |
In the original code, a reference to a temporary struct created by the to_ll function is created. This struct lives only inside of lambda, but the reference is then converted to a pointer, so the borrow checker can't catch it. I have created similar code in safe rust which shows the error exactly |
I believe there are additional issues in the code. This pattern appears frequently:
The same problem occurs here as well. A temporary structure is created using |
i don't know if this is an issue with this crate or sdl3-sys, but Canvas::fill_rect does not work at all, when passing in an FRect. draw_rect works just fine.
System:
Fedora 41
Wayland
Nvidia RTX 3080
using version 0.11 and feature build-from-source
The text was updated successfully, but these errors were encountered: