Fix buffer out-of-bounds in application example draw#4481
Fix buffer out-of-bounds in application example draw#4481TarekAS wants to merge 1 commit intorust-windowing:masterfrom
Conversation
…f.window.surface_size() for loop bounds, but self.surface.buffer_mut() returns a buffer sized by the last resize() call. When the window resizes, surface_size() can return new dimensions before the buffer is resized to match, causing an index out-of-bounds panic. Store the size from resize() and use it in draw() instead.
There was a problem hiding this comment.
I tend to think that the real bug here is that Winit updates Window::surface_size before the user has received an event for it, see also #3690.
In any case, this should also be fixed after rust-windowing/softbuffer#237 (which should land in the next version of softbuffer, because then the drawing always uses the actual bounds of the surface.
Idk. whether it makes sense to update the example in the meantime.
Edit: apologies for the long PR title, used the original commit message for it.
You can edit it ;)
|
Would be great to fix the root cause of this issue. In the meantime, the application example is broken while it was working in 0.30. I had to do this workaround in order to contribute to another PR |
Fixes broken example: #4480
At least on macOS
changelogmodule if knowledge of this change could be valuable to usersEdit: apologies for the long PR title, used the original commit message for it.