wayland: fix deadlock in SurfaceData::cleanup (#166)

This commit is contained in:
Ivan Molodetskikh 2020-02-16 18:38:07 +03:00 committed by GitHub
parent a60e1cd7fd
commit e42ccc8aee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -74,11 +74,12 @@ where
} }
// orphan all our children // orphan all our children
for child in &my_data.children { for child in &my_data.children {
// don't do anything if this child is ourselves let child_mutex = child.as_ref().user_data::<Mutex<SurfaceData<R>>>().unwrap();
if child.as_ref().equals(surface.as_ref()) { if std::ptr::eq(child_mutex, my_data_mutex) {
// This child is ourselves, don't do anything.
continue; continue;
} }
let child_mutex = child.as_ref().user_data::<Mutex<SurfaceData<R>>>().unwrap();
let mut child_guard = child_mutex.lock().unwrap(); let mut child_guard = child_mutex.lock().unwrap();
child_guard.parent = None; child_guard.parent = None;
} }