wayland.shell: don't access the data of dead surfaces during cleanup
This commit is contained in:
parent
d267a89ba9
commit
4bd1501b96
|
@ -1,3 +1 @@
|
|||
|
||||
|
||||
mod wl_handlers;
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -224,6 +224,12 @@ fn destroy_surface<U, R, SD>(
|
|||
surface.set_user_data(::std::ptr::null_mut());
|
||||
// take back ownership of the userdata
|
||||
let data = unsafe { Box::from_raw(ptr as *mut XdgSurfaceUserData) };
|
||||
if !data.0.is_alive() {
|
||||
// the wl_surface is destroyed, this means the client is not
|
||||
// trying to change the role but it's a cleanup (possibly a
|
||||
// disconnecting client), ignore the protocol check.
|
||||
return;
|
||||
}
|
||||
implem
|
||||
.compositor_token
|
||||
.with_role_data::<ShellSurfaceRole, _, _>(&data.0, |rdata| {
|
||||
|
@ -582,6 +588,12 @@ fn destroy_toplevel<U, R, SD>(
|
|||
toplevel.set_user_data(::std::ptr::null_mut());
|
||||
// take back ownership of the userdata
|
||||
let data = *unsafe { Box::from_raw(ptr as *mut ShellSurfaceUserData) };
|
||||
if !data.0.is_alive() {
|
||||
// the wl_surface is destroyed, this means the client is not
|
||||
// trying to change the role but it's a cleanup (possibly a
|
||||
// disconnecting client), ignore the protocol check.
|
||||
return;
|
||||
} else {
|
||||
implem
|
||||
.compositor_token
|
||||
.with_role_data::<ShellSurfaceRole, _, _>(&data.0, |data| {
|
||||
|
@ -589,18 +601,14 @@ fn destroy_toplevel<U, R, SD>(
|
|||
data.configured = false;
|
||||
})
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
}
|
||||
// remove this surface from the known ones (as well as any leftover dead surface)
|
||||
implem
|
||||
.shell_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.known_toplevels
|
||||
.retain(|other| {
|
||||
other
|
||||
.get_surface()
|
||||
.map(|s| !s.equals(&data.0))
|
||||
.unwrap_or(false)
|
||||
});
|
||||
.retain(|other| other.alive());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -688,6 +696,12 @@ fn destroy_popup<U, R, SD>(
|
|||
popup.set_user_data(::std::ptr::null_mut());
|
||||
// take back ownership of the userdata
|
||||
let data = *unsafe { Box::from_raw(ptr as *mut ShellSurfaceUserData) };
|
||||
if !data.0.is_alive() {
|
||||
// the wl_surface is destroyed, this means the client is not
|
||||
// trying to change the role but it's a cleanup (possibly a
|
||||
// disconnecting client), ignore the protocol check.
|
||||
return;
|
||||
} else {
|
||||
implem
|
||||
.compositor_token
|
||||
.with_role_data::<ShellSurfaceRole, _, _>(&data.0, |data| {
|
||||
|
@ -695,16 +709,12 @@ fn destroy_popup<U, R, SD>(
|
|||
data.configured = false;
|
||||
})
|
||||
.expect("xdg_popup exists but surface has not shell_surface role?!");
|
||||
}
|
||||
// remove this surface from the known ones (as well as any leftover dead surface)
|
||||
implem
|
||||
.shell_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.known_popups
|
||||
.retain(|other| {
|
||||
other
|
||||
.get_surface()
|
||||
.map(|s| !s.equals(&data.0))
|
||||
.unwrap_or(false)
|
||||
});
|
||||
.retain(|other| other.alive());
|
||||
}
|
||||
|
|
|
@ -240,6 +240,12 @@ fn destroy_surface<U, R, SD>(
|
|||
surface.set_user_data(::std::ptr::null_mut());
|
||||
// take back ownership of the userdata
|
||||
let data = unsafe { Box::from_raw(ptr as *mut XdgSurfaceUserData) };
|
||||
if !data.0.is_alive() {
|
||||
// the wl_surface is destroyed, this means the client is not
|
||||
// trying to change the role but it's a cleanup (possibly a
|
||||
// disconnecting client), ignore the protocol check.
|
||||
return;
|
||||
}
|
||||
implem
|
||||
.compositor_token
|
||||
.with_role_data::<ShellSurfaceRole, _, _>(&data.0, |rdata| {
|
||||
|
@ -603,6 +609,12 @@ fn destroy_toplevel<U, R, SD>(
|
|||
toplevel.set_user_data(::std::ptr::null_mut());
|
||||
// take back ownership of the userdata
|
||||
let data = *unsafe { Box::from_raw(ptr as *mut ShellSurfaceUserData) };
|
||||
if !data.0.is_alive() {
|
||||
// the wl_surface is destroyed, this means the client is not
|
||||
// trying to change the role but it's a cleanup (possibly a
|
||||
// disconnecting client), ignore the protocol check.
|
||||
return;
|
||||
} else {
|
||||
implem
|
||||
.compositor_token
|
||||
.with_role_data::<ShellSurfaceRole, _, _>(&data.0, |data| {
|
||||
|
@ -610,18 +622,14 @@ fn destroy_toplevel<U, R, SD>(
|
|||
data.configured = false;
|
||||
})
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
}
|
||||
// remove this surface from the known ones (as well as any leftover dead surface)
|
||||
implem
|
||||
.shell_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.known_toplevels
|
||||
.retain(|other| {
|
||||
other
|
||||
.get_surface()
|
||||
.map(|s| !s.equals(&data.0))
|
||||
.unwrap_or(false)
|
||||
});
|
||||
.retain(|other| other.alive());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -709,6 +717,12 @@ fn destroy_popup<U, R, SD>(
|
|||
popup.set_user_data(::std::ptr::null_mut());
|
||||
// take back ownership of the userdata
|
||||
let data = *unsafe { Box::from_raw(ptr as *mut ShellSurfaceUserData) };
|
||||
if !data.0.is_alive() {
|
||||
// the wl_surface is destroyed, this means the client is not
|
||||
// trying to change the role but it's a cleanup (possibly a
|
||||
// disconnecting client), ignore the protocol check.
|
||||
return;
|
||||
} else {
|
||||
implem
|
||||
.compositor_token
|
||||
.with_role_data::<ShellSurfaceRole, _, _>(&data.0, |data| {
|
||||
|
@ -716,18 +730,14 @@ fn destroy_popup<U, R, SD>(
|
|||
data.configured = false;
|
||||
})
|
||||
.expect("xdg_popup exists but surface has not shell_surface role?!");
|
||||
}
|
||||
// remove this surface from the known ones (as well as any leftover dead surface)
|
||||
implem
|
||||
.shell_state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.known_popups
|
||||
.retain(|other| {
|
||||
other
|
||||
.get_surface()
|
||||
.map(|s| !s.equals(&data.0))
|
||||
.unwrap_or(false)
|
||||
});
|
||||
.retain(|other| other.alive());
|
||||
}
|
||||
|
||||
fn zxdg_edges_to_xdg(e: zxdg_toplevel_v6::ResizeEdge) -> xdg_toplevel::ResizeEdge {
|
||||
|
|
Loading…
Reference in New Issue