[gnome-shell/gnome-3-28] windowMenu: Check if monitorIndex is valid before using it



commit a662e7bb8718f5dac99cde76750b04d1310c5efd
Author: Sam Spilsbury <sam endlessm com>
Date:   Wed Oct 11 10:42:04 2017 +0000

    windowMenu: Check if monitorIndex is valid before using it
    
    Calling meta_window_get_monitor on an unmanaged window may return
    -1, so we need to check the return value.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788882
    
    
    (cherry picked from commit c9bf72c5c4e8a94ff66fd191cb79165bed2831e5)

 js/ui/windowMenu.js | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/windowMenu.js b/js/ui/windowMenu.js
index f0e564b7e..d4411d015 100644
--- a/js/ui/windowMenu.js
+++ b/js/ui/windowMenu.js
@@ -128,11 +128,10 @@ var WindowMenu = new Lang.Class({
 
         let screen = global.screen;
         let nMonitors = screen.get_n_monitors();
-        if (nMonitors > 1) {
+        let monitorIndex = window.get_monitor();
+        if (nMonitors > 1 && monitorIndex >= 0) {
             this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
 
-            let monitorIndex = window.get_monitor();
-
             let dir = Meta.ScreenDirection.UP;
             let upMonitorIndex =
                 screen.get_monitor_neighbor_index(monitorIndex, dir);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]