Panel: fix finding leftmost and rightmost buttons

Previous code would access the array element before checking that
the index was within bounds, and therefore cause a TypeError.
It wasn't noticed earlier because at least one visible children
is in each panel box in all session modes.

https://bugzilla.gnome.org/show_bug.cgi?id=619955
This commit is contained in:
Giovanni Campagna 2012-07-17 19:27:43 +02:00
parent f5e58c500f
commit d9c3b83d1e

View File

@ -753,10 +753,11 @@ const PanelCorner = new Lang.Class({
return null; return null;
// Start at the back and work backward // Start at the back and work backward
let index = children.length - 1; let index;
while (!children[index].visible && index >= 0) for (index = children.length - 1; index >= 0; index--) {
index--; if (children[index].visible)
break;
}
if (index < 0) if (index < 0)
return null; return null;
@ -777,10 +778,11 @@ const PanelCorner = new Lang.Class({
return null; return null;
// Start at the front and work forward // Start at the front and work forward
let index = 0; let index;
while (!children[index].visible && index < children.length) for (index = 0; index < children.length; index++) {
index++; if (children[index].visible)
break;
}
if (index == children.length) if (index == children.length)
return null; return null;