desktop-shell: don't crash if a surface disappears while grabbed
A surface can get destroyed while a shell grab is active, which can
for example happen if the command running in weston-terminal
exits. (Test this by opening weston-terminal
, starting to interactively rotate it and pressing Ctrl-D to exit the shell.)
When a surface gets destroyed, grab->shsurf
is reset to NULL
by
destroy_shell_grab_shsurf()
, but otherwise the grab remains active and
its callbacks continue to be called. Thus, dereferencing grab->shsurf
in a callback without checking it for NULL
first can lead to undefined
behavior, including crashes.
Several functions were already properly checking grab->shsurf
for NULL
,
move_grab_motion()
being one example. Others, however, were not, which
is what this commit fixes.
Related to #192 (closed), but does not actually include the patch from 79a09166 which fixes the same problem in resize_grab_button()
and as the result fixes #192 (closed). It is expected that this gets applied on top of 79a09166 (though they don't conflict with each other and can be applied in any order).