later: Handle gracefully calls with unset display

This can happen when the display has been already closed, in such case
we should not crash but warn about the error and return early.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1780>
This commit is contained in:
Marco Trevisan (Treviño) 2021-03-13 06:20:40 +01:00 committed by Marge Bot
parent 42287a5f04
commit 2744722b8c

View File

@ -277,8 +277,12 @@ meta_later_add (MetaLaterType when,
GDestroyNotify notify) GDestroyNotify notify)
{ {
MetaDisplay *display = meta_get_display (); MetaDisplay *display = meta_get_display ();
MetaCompositor *compositor = display->compositor; MetaCompositor *compositor;
g_return_val_if_fail (display, 0);
g_return_val_if_fail (display->compositor, 0);
compositor = display->compositor;
return meta_laters_add (meta_compositor_get_laters (compositor), return meta_laters_add (meta_compositor_get_laters (compositor),
when, func, data, notify); when, func, data, notify);
} }
@ -306,8 +310,11 @@ void
meta_later_remove (unsigned int later_id) meta_later_remove (unsigned int later_id)
{ {
MetaDisplay *display = meta_get_display (); MetaDisplay *display = meta_get_display ();
MetaCompositor *compositor = display->compositor; MetaCompositor *compositor;
g_return_if_fail (display);
compositor = display->compositor;
if (!compositor) if (!compositor)
return; return;