From c7a98cee21197a2ec50e42118fcae59406d50afd Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Sun, 26 Apr 2020 17:32:16 +0200 Subject: [PATCH] atomic: do not allow removal of the last connector --- src/backend/drm/atomic/surface.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/backend/drm/atomic/surface.rs b/src/backend/drm/atomic/surface.rs index 6590ecf..842e04f 100644 --- a/src/backend/drm/atomic/surface.rs +++ b/src/backend/drm/atomic/surface.rs @@ -285,6 +285,11 @@ impl Surface for AtomicDrmSurfaceInternal { let mut pending = self.pending.write().unwrap(); + // the test would also prevent this, but the error message is far less helpful + if pending.connectors.contains(&conn) && pending.connectors.len() == 1 { + return Err(Error::SurfaceWithoutConnectors(self.crtc)); + } + // check if new config is supported (should be) let req = self.build_request( &mut [].iter(), @@ -308,6 +313,10 @@ impl Surface for AtomicDrmSurfaceInternal { } fn set_connectors(&self, connectors: &[connector::Handle]) -> Result<(), Error> { + if connectors.is_empty() { + return Err(Error::SurfaceWithoutConnectors(self.crtc)); + } + if !self.dev.active.load(Ordering::SeqCst) { return Err(Error::DeviceInactive); }