anvil: don't release SHM buffers twice
This commit is contained in:
parent
484f2cd14f
commit
01b5c1a183
|
@ -123,30 +123,32 @@ where
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let result = renderer.import_shm_buffer(&buffer, Some(&attributes), &damage);
|
let result = renderer.import_shm_buffer(&buffer, Some(&attributes), &damage);
|
||||||
if result.is_ok() {
|
buffer.release();
|
||||||
buffer.release();
|
// don't return the buffer as it is already released
|
||||||
}
|
Some((result, None))
|
||||||
Some(result)
|
|
||||||
},
|
},
|
||||||
#[cfg(feature = "egl")]
|
#[cfg(feature = "egl")]
|
||||||
Some(BufferType::Egl) => Some(renderer.import_egl_buffer(&buffer, egl_buffer_reader.unwrap())),
|
Some(BufferType::Egl) => Some((renderer.import_egl_buffer(&buffer, egl_buffer_reader.unwrap()), Some(buffer))),
|
||||||
Some(BufferType::Dma) => Some(renderer.import_dma_buffer(&buffer)),
|
Some(BufferType::Dma) => Some((renderer.import_dma_buffer(&buffer), Some(buffer))),
|
||||||
_ => {
|
_ => {
|
||||||
error!(log, "Unknown buffer format for: {:?}", buffer);
|
error!(log, "Unknown buffer format for: {:?}", buffer);
|
||||||
|
buffer.release();
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match texture {
|
match texture {
|
||||||
Some(Ok(m)) => {
|
Some((Ok(m), buffer)) => {
|
||||||
data.texture = Some(Box::new(BufferTextures { buffer: Some(buffer), texture: m })
|
data.texture = Some(Box::new(BufferTextures { buffer, texture: m })
|
||||||
as Box<dyn std::any::Any + 'static>)
|
as Box<dyn std::any::Any + 'static>)
|
||||||
}
|
}
|
||||||
// there was an error reading the buffer, release it.
|
// there was an error reading the buffer, release it.
|
||||||
Some(Err(err)) => {
|
Some((Err(err), buffer)) => {
|
||||||
warn!(log, "Error loading buffer: {:?}", err);
|
warn!(log, "Error loading buffer: {:?}", err);
|
||||||
buffer.release();
|
if let Some(buffer) = buffer {
|
||||||
|
buffer.release();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
None => buffer.release(),
|
None => {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue