it: track whether objects have been deleted
This commit is contained in:
parent
cdab4d4cad
commit
6af9d909b8
22 changed files with 167 additions and 45 deletions
|
|
@ -2,7 +2,9 @@ use {
|
|||
crate::{
|
||||
ifs::wl_surface::WlSurface,
|
||||
it::{
|
||||
test_error::TestError, test_object::TestObject, test_transport::TestTransport,
|
||||
test_error::TestError,
|
||||
test_object::{Deleted, TestObject},
|
||||
test_transport::TestTransport,
|
||||
testrun::ParseFull,
|
||||
},
|
||||
utils::buffd::MsgParser,
|
||||
|
|
@ -16,26 +18,33 @@ pub struct TestSurface {
|
|||
pub tran: Rc<TestTransport>,
|
||||
pub server: Rc<WlSurface>,
|
||||
pub destroyed: Cell<bool>,
|
||||
pub deleted: Deleted,
|
||||
}
|
||||
|
||||
impl TestSurface {
|
||||
pub fn destroy(&self) {
|
||||
pub fn destroy(&self) -> Result<(), TestError> {
|
||||
if !self.destroyed.replace(true) {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Destroy { self_id: self.id });
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn attach(&self, buffer_id: WlBufferId) {
|
||||
pub fn attach(&self, buffer_id: WlBufferId) -> Result<(), TestError> {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Attach {
|
||||
self_id: self.id,
|
||||
buffer: buffer_id,
|
||||
x: 0,
|
||||
y: 0,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn commit(&self) {
|
||||
pub fn commit(&self) -> Result<(), TestError> {
|
||||
self.deleted.check()?;
|
||||
self.tran.send(Commit { self_id: self.id });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_enter(&self, parser: MsgParser<'_, '_>) -> Result<(), TestError> {
|
||||
|
|
@ -51,7 +60,7 @@ impl TestSurface {
|
|||
|
||||
impl Drop for TestSurface {
|
||||
fn drop(&mut self) {
|
||||
self.destroy();
|
||||
let _ = self.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue