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>(
&mut self,
used_devices: &HashSet<DrmNode>,
mut others: impl Iterator<Item = &'b Self>,
others: &[&'b mut Self],
) -> Result<()>
where
Self: 'b,
@ -891,7 +891,10 @@ impl InnerDevice {
self.gbm.clone(),
)
} 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.egl.as_ref().unwrap(),

View file

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