From 2b2b6bc7cea183e0734258babea4cf393e8ee9cb Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Wed, 4 Jan 2017 20:52:37 +0100 Subject: [PATCH] Fix scrollingPeriod_ in case of incorrect initialisation or update. --- RetroFE/Source/Graphics/Component/ScrollingList.cpp | 10 +++++++++- RetroFE/Source/RetroFE.cpp | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index f2a5abc..ceb938b 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -78,7 +78,7 @@ ScrollingList::ScrollingList(const ScrollingList ©) , selectedOffsetIndex_(copy.selectedOffsetIndex_) , scrollAcceleration_(copy.scrollAcceleration_) , startScrollTime_(copy.startScrollTime_) - , scrollPeriod_(0) + , scrollPeriod_(copy.startScrollTime_) , config_(copy.config_) , scaleX_(copy.scaleX_) , scaleY_(copy.scaleY_) @@ -367,6 +367,14 @@ void ScrollingList::triggerHighlightExitEvent( int menuIndex ) void ScrollingList::update(float dt) { + + // Check if scrollPeriod_ has been properly initialised already or if something went wrong + // while updating the scrollPeriod_ + if(scrollPeriod_ < scrollAcceleration_) + { + scrollPeriod_ = startScrollTime_; + } + Component::update(dt); if(components_.size() == 0) return; diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index f2b59aa..6bcf343 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -313,7 +313,6 @@ void RetroFE::run() case RETROFE_ENTER: if(currentPage_->isIdle()) { - currentPage_->resetScrollPeriod(); state = RETROFE_IDLE; } break;