anvil: release old buffers on commit

This commit is contained in:
Victor Brekenfeld 2019-08-23 15:15:52 +02:00
parent 1627d51cf6
commit 056a86ad30
1 changed files with 6 additions and 2 deletions

View File

@ -143,13 +143,17 @@ fn surface_commit(surface: &wl_surface::WlSurface, token: CompositorToken<Roles>
// new contents
// TODO: handle hotspot coordinates
let data = attributes.user_data.get_mut::<SurfaceData>().unwrap();
data.buffer = Some(buffer);
if let Some(old_buffer) = data.buffer.replace(buffer) {
old_buffer.release();
}
data.texture = None;
}
Some(None) => {
// erase the contents
let data = attributes.user_data.get_mut::<SurfaceData>().unwrap();
data.buffer = None;
if let Some(old_buffer) = data.buffer.take() {
old_buffer.release();
}
data.texture = None;
}
None => {}