raise shared_data update (#68)

This helps the check_buffer_size run against the actual
window size, which stops us from segfaulting if the
window size has changed unexpectedly, e.g. because a
window manager is evil.
This commit is contained in:
Chris West 2019-03-14 15:29:59 +00:00 committed by Daniel Collin
parent ceadd15e6c
commit ac624f5a26

View file

@ -236,6 +236,10 @@ impl Window {
pub fn update_with_buffer(&mut self, buffer: &[u32]) -> Result<()> { pub fn update_with_buffer(&mut self, buffer: &[u32]) -> Result<()> {
self.key_handler.update(); self.key_handler.update();
unsafe {
Self::set_shared_data(self);
}
let check_res = buffer_helper::check_buffer_size(self.shared_data.width as usize, let check_res = buffer_helper::check_buffer_size(self.shared_data.width as usize,
self.shared_data.height as usize, self.shared_data.height as usize,
self.shared_data.scale as usize, self.shared_data.scale as usize,
@ -245,7 +249,6 @@ impl Window {
} }
unsafe { unsafe {
Self::set_shared_data(self);
mfb_update_with_buffer(self.window_handle, buffer.as_ptr() as *const u8); mfb_update_with_buffer(self.window_handle, buffer.as_ptr() as *const u8);
mfb_set_key_callback(self.window_handle, mfb_set_key_callback(self.window_handle,
mem::transmute(self), mem::transmute(self),