[gnome-shell] Panel: fix finding leftmost and rightmost buttons
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Panel: fix finding leftmost and rightmost buttons
- Date: Sat, 21 Jul 2012 13:41:23 +0000 (UTC)
commit d9c3b83d1ed4e5b04d4ef36e383b206203d5370d
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Tue Jul 17 19:27:43 2012 +0200
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
js/ui/panel.js | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index c969381..648a677 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]