anvil.glium_drawer: fix buffer release order

This commit is contained in:
Victor Berger 2019-04-10 15:24:17 +02:00 committed by Victor Berger
parent 9f9e6d4329
commit 0712bdefec
2 changed files with 17 additions and 4 deletions

View File

@ -11,7 +11,7 @@ edition = "2018"
members = [ "anvil" ]
[dependencies]
wayland-server = { version = "0.23", optional = true }
wayland-server = { version = "0.23.2", optional = true }
wayland-commons = { version = "0.23", optional = true }
wayland-sys = { version = "0.23", optional = true }
calloop = "0.4.2"

View File

@ -302,11 +302,24 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
if attributes.user_data.texture.is_none() {
if let Some(buffer) = attributes.user_data.buffer.take() {
if let Ok(m) = self.texture_from_buffer(buffer.clone()) {
// release the buffer if it was an SHM buffer
#[cfg(feature = "egl")]
{
if m.images.is_none() {
buffer.release();
}
}
#[cfg(not(feature = "egl"))]
{
buffer.release();
}
attributes.user_data.texture = Some(m);
} else {
// there was an error reading the buffer, release it, we
// already logged the error
buffer.release();
}
// notify the client that we have finished reading the
// buffer
buffer.release();
}
}
// Now, should we be drawn ?