Endless loops in keyup/down handlers
Commit Message
Hello,
when MenuScrollWrap is activated, menues are going into an endless loop
when there are no selectable items. E.g. after 'Recordings' -> 1 -> Up,
vdr does not respond anymore. Same happens for non-empty menues which do
not have selectable items.
The attached patch fixes this (written for 1.3.33, but applies to 1.3.34
too).
Enrico
2005-10-03 17:52 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
- osdbase.c: prevent an endless loop in the keyup/down handlers
when no selectable entries are available and MenuScrollWrap
is activated
@@ -266,14 +266,17 @@
int tmpCurrent = current;
int lastOnScreen = first + displayMenuItems - 1;
int last = Count() - 1;
+ if (last==-1)
+ return;
+
while (--tmpCurrent != current) {
if (tmpCurrent < 0) {
if (Setup.MenuScrollWrap)
- tmpCurrent = last;
+ tmpCurrent = last+1;
else
return;
}
- if (SelectableItem(tmpCurrent))
+ else if (SelectableItem(tmpCurrent))
break;
}
if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
@@ -296,14 +299,17 @@
int tmpCurrent = current;
int lastOnScreen = first + displayMenuItems - 1;
int last = Count() - 1;
+ if (last==-1)
+ return;
+
while (++tmpCurrent != current) {
if (tmpCurrent > last) {
if (Setup.MenuScrollWrap)
- tmpCurrent = 0;
+ tmpCurrent = -1;
else
return;
}
- if (SelectableItem(tmpCurrent))
+ else if (SelectableItem(tmpCurrent))
break;
}
if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)