From 2744722b8cb06540c26b82c5e49c6546b4437554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 13 Mar 2021 06:20:40 +0100 Subject: [PATCH] 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: --- src/compositor/meta-later.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compositor/meta-later.c b/src/compositor/meta-later.c index 61fa97f14..43da6d8e6 100644 --- a/src/compositor/meta-later.c +++ b/src/compositor/meta-later.c @@ -277,8 +277,12 @@ meta_later_add (MetaLaterType when, GDestroyNotify notify) { 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), when, func, data, notify); } @@ -306,8 +310,11 @@ void meta_later_remove (unsigned int later_id) { MetaDisplay *display = meta_get_display (); - MetaCompositor *compositor = display->compositor; + MetaCompositor *compositor; + g_return_if_fail (display); + + compositor = display->compositor; if (!compositor) return;