Author: stippi Date: 2010-09-06 11:21:12 +0200 (Mon, 06 Sep 2010) New Revision: 38540 Changeset: http://dev.haiku-os.org/changeset/38540 Modified: haiku/trunk/src/apps/mediaplayer/ControllerView.cpp Log: -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. Modified: haiku/trunk/src/apps/mediaplayer/ControllerView.cpp =================================================================== --- haiku/trunk/src/apps/mediaplayer/ControllerView.cpp 2010-09-06 09:15:31 UTC (rev 38539) +++ haiku/trunk/src/apps/mediaplayer/ControllerView.cpp 2010-09-06 09:21:12 UTC (rev 38540) @@ -135,7 +135,10 @@ 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 @@ 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); }