kms: Don't incorrectly re-use iterator in update_surface_nodes

This commit is contained in:
Victoria Brekenfeld 2025-07-28 17:18:11 +02:00 committed by Victoria Brekenfeld
parent 6492629f90
commit fd85e4ea56
2 changed files with 11 additions and 10 deletions

View file

@ -872,7 +872,7 @@ impl InnerDevice {
pub fn update_surface_nodes<'b>( pub fn update_surface_nodes<'b>(
&mut self, &mut self,
used_devices: &HashSet<DrmNode>, used_devices: &HashSet<DrmNode>,
mut others: impl Iterator<Item = &'b Self>, others: &[&'b mut Self],
) -> Result<()> ) -> Result<()>
where where
Self: 'b, Self: 'b,
@ -891,7 +891,10 @@ impl InnerDevice {
self.gbm.clone(), self.gbm.clone(),
) )
} else { } else {
let device = others.find(|d| d.render_node == *new_device).unwrap(); let device = others
.iter()
.find(|d| d.render_node == *new_device)
.unwrap();
( (
device.render_node, device.render_node,
device.egl.as_ref().unwrap(), device.egl.as_ref().unwrap(),

View file

@ -571,10 +571,9 @@ impl KmsState {
let (mut device, others) = self let (mut device, others) = self
.drm_devices .drm_devices
.values_mut() .values_mut()
.partition::<Vec<_>, _>(|d| d.inner.render_node == node); .map(|d| &mut d.inner)
device[0] .partition::<Vec<_>, _>(|d| d.render_node == node);
.inner device[0].update_surface_nodes(&used_devices, &others)?;
.update_surface_nodes(&used_devices, others.iter().map(|device| &device.inner))?;
} }
Ok(()) Ok(())
@ -634,10 +633,9 @@ impl<'a> KmsGuard<'a> {
let (mut device, others) = self let (mut device, others) = self
.drm_devices .drm_devices
.values_mut() .values_mut()
.partition::<Vec<_>, _>(|d| d.inner.render_node == node); .map(|d| &mut *d.inner)
device[0] .partition::<Vec<_>, _>(|d| d.render_node == node);
.inner device[0].update_surface_nodes(&used_devices, &others)?;
.update_surface_nodes(&used_devices, others.iter().map(|device| &*device.inner))?;
} }
Ok(()) Ok(())