legacy: do not allow removal of the last connector

This commit is contained in:
Victor Brekenfeld 2020-04-26 17:06:32 +02:00
parent 4786db633b
commit c560aef666
1 changed files with 11 additions and 1 deletions

View File

@ -129,11 +129,21 @@ impl<A: AsRawFd + 'static> Surface for LegacyDrmSurfaceInternal<A> {
}
fn remove_connector(&self, connector: connector::Handle) -> Result<(), Error> {
self.pending.write().unwrap().connectors.remove(&connector);
let mut pending = self.pending.write().unwrap();
if pending.connectors.contains(&connector) && pending.connectors.len() == 1 {
return Err(Error::SurfaceWithoutConnectors(self.crtc));
}
pending.connectors.remove(&connector);
Ok(())
}
fn set_connectors(&self, connectors: &[connector::Handle]) -> Result<(), Self::Error> {
if connectors.is_empty() {
return Err(Error::SurfaceWithoutConnectors(self.crtc));
}
if !self.dev.active.load(Ordering::SeqCst) {
return Err(Error::DeviceInactive);
}