[gnome-shell/gnome-3-4] popupMenu: do not overflow the currentItems



commit 717aedec5d139f42760644fdf3f2013fba7b7689
Author: Alban Browaeys <prahal yahoo com>
Date:   Sun May 20 23:36:27 2012 +0200

    popupMenu: do not overflow the currentItems
    
    Do not overflow currentItems array. If the Menu section is filled
    via model items-changed callback the position in the model passed to
    the RemoteMenu _modelChanged can be a to be added asynchronously
    action-added. Thus the item does not yet exists in the currentItems.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676447

 js/ui/popupMenu.js |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index ad1c71a..7d5bfe7 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -1917,7 +1917,7 @@ const RemoteMenu = new Lang.Class({
         while (k0 < currentItems.length && currentItems[k0]._ignored)
             k0++;
         // find the right menu item matching the model item
-        for (j0 = 0; j0 < position; j0++, k0++) {
+        for (j0 = 0; k0 < currentItems.length && j0 < position; j0++, k0++) {
             if (currentItems[k0]._ignored)
                 k0++;
         }
@@ -1927,7 +1927,7 @@ const RemoteMenu = new Lang.Class({
             for (k = k0; k < currentItems.length; k++)
                 currentItems[k].destroy();
         } else {
-            for (j = j0, k = k0; j < j0 + removed; j++, k++) {
+            for (j = j0, k = k0; k < currentItems.length && j < j0 + removed; j++, k++) {
                 currentItems[k].destroy();
 
                 if (currentItems[k]._ignored)



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