do not release the buffer if old == new
if the same buffer is attached multiple times
releasing the old buffer will also release
the new buffer
@@ -189,9 +189,16 @@ impl Cacheable for SurfaceAttributes {
if let Some(BufferAssignment::NewBuffer { buffer, .. }) =
std::mem::replace(&mut into.buffer, self.buffer)
{
+ let new_buffer = into.buffer.as_ref().and_then(|b| match b {
+ BufferAssignment::Removed => None,
+ BufferAssignment::NewBuffer { buffer, .. } => Some(buffer),
+ });
+
+ if Some(&buffer) != new_buffer {
buffer.release();
}
}
+ }
into.buffer_scale = self.buffer_scale;
into.buffer_transform = self.buffer_transform;
into.damage.extend(self.damage);
