-1 is a valid index for the current playlist item index

in the Playlist code, but we don't want to get to this
index from the GUI. Handle truncation of the index in
the ControllerView. This solves invalid button state
when using the keyboard to skip to the previous item
when the current item was already the first item.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38540 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-09-06 09:21:12 +00:00
parent 45f82fe6d0
commit 11c015d896

View File

@ -135,7 +135,10 @@ void
ControllerView::SkipBackward()
{
BAutolock _(fPlaylist);
fPlaylist->SetCurrentItemIndex(fPlaylist->CurrentItemIndex() - 1);
int32 index = fPlaylist->CurrentItemIndex() - 1;
if (index < 0)
index = 0;
fPlaylist->SetCurrentItemIndex(index);
}
@ -143,7 +146,10 @@ void
ControllerView::SkipForward()
{
BAutolock _(fPlaylist);
fPlaylist->SetCurrentItemIndex(fPlaylist->CurrentItemIndex() + 1);
int32 index = fPlaylist->CurrentItemIndex() + 1;
if (index >= fPlaylist->CountItems())
index = fPlaylist->CountItems() - 1;
fPlaylist->SetCurrentItemIndex(index);
}