From 11c015d896817881aa8bfa151dad4480460bbbdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 6 Sep 2010 09:21:12 +0000 Subject: [PATCH] -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 --- src/apps/mediaplayer/ControllerView.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/apps/mediaplayer/ControllerView.cpp b/src/apps/mediaplayer/ControllerView.cpp index 4c9f03499b..4bc98e6a39 100644 --- a/src/apps/mediaplayer/ControllerView.cpp +++ b/src/apps/mediaplayer/ControllerView.cpp @@ -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); }