From: Sam Spilsbury Date: Tue, 10 Oct 2017 16:39:40 +0000 (-0500) Subject: core: Return -1 if meta_window_get_monitor is called on an unmanaged window X-Git-Tag: archive/raspbian/3.28.3-1+rpi1^2~5 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e138356ada0f083d32e89ccbf8f9ece487d9da2f;p=mutter.git core: Return -1 if meta_window_get_monitor is called on an unmanaged window As opposed to crashing. In this case, letting the caller deal with it is the best policy, since this is public API. Fixes #78834 Forwarded: yes Bug: https://bugzilla.gnome.org/show_bug.cgi?id=788834 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/bionic/+source/gnome-shell/+bug/1724439 Gbp-Pq: Name core-Return-1-if-meta_window_get_monitor-is-called-on-an-.patch --- diff --git a/src/core/window.c b/src/core/window.c index 743326c..441b5be 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -3750,11 +3750,16 @@ maybe_move_attached_dialog (MetaWindow *window, * * Gets index of the monitor that this window is on. * - * Return Value: The index of the monitor in the screens monitor list + * Return Value: The index of the monitor in the screens monitor list, or -1 + * if the window has been recently unmanaged and does not have + * a monitor. */ int meta_window_get_monitor (MetaWindow *window) { + if (!window->monitor) + return -1; + return window->monitor->number; }