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