Merge pull request #144 from Smithay/pr/fix/anvil_buffer_leak

anvil: release old buffers on commit
This commit is contained in:
Victor Brekenfeld 2019-08-23 16:50:14 +02:00 committed by GitHub
commit f8f4f461c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 // new contents
// TODO: handle hotspot coordinates // TODO: handle hotspot coordinates
let data = attributes.user_data.get_mut::<SurfaceData>().unwrap(); 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; data.texture = None;
} }
Some(None) => { Some(None) => {
// erase the contents // erase the contents
let data = attributes.user_data.get_mut::<SurfaceData>().unwrap(); 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; data.texture = None;
} }
None => {} None => {}