linuxstb / pidvbip

tvheadend client for the Raspberry Pi
http://www.pidvbip.org
GNU General Public License v2.0
53 stars 22 forks source link

channels_getprev() returns wrong channel #22

Closed eindano closed 11 years ago

eindano commented 11 years ago

If current channel is the first in the channel list channels_getprev() will not return the last channel in the list. Instead the next to last channel will be returned.

To fix this move channels_cache = p; statement out from the while loop.

Correct code:

int channels_getprev(int id) { struct channel_t* p = find_channel(id);

if (p==NULL) { return channels_getfirst(); } else { channels_cache = p->prev; if (p->prev == NULL) { p = channels; while (p->next != NULL) { //channels_cache = p; // remove this line p = p->next; } channels_cache = p; // new line }

return channels_cache->id;

} }

linuxstb commented 11 years ago

Good spot, thanks I've now committed this change.