From ea22b945415627195b19a79203131fae56c49025 Mon Sep 17 00:00:00 2001 From: chitta ranjan Date: Mon, 22 Apr 2013 18:18:47 +0900 Subject: [PATCH] Fixed issue 35692 Change-Id: If5e0b1ac61ffc398fad3d908fed9f54de054fac1 Signed-off-by: chitta ranjan --- src/IvImageViewerForm.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/IvImageViewerForm.cpp b/src/IvImageViewerForm.cpp index c396fcf..dfb5249 100644 --- a/src/IvImageViewerForm.cpp +++ b/src/IvImageViewerForm.cpp @@ -1959,6 +1959,9 @@ void ImageViewerForm::CreateShuffledList(int count) { AppLogDebug("ENTER"); + + int origIndex = 0; + int curPos = 0; if (__pShuffledList == null) { __pShuffledList = new (std::nothrow) int[count]; @@ -1967,13 +1970,28 @@ ImageViewerForm::CreateShuffledList(int count) __pShuffledList[i] = i; } } + origIndex = __shuffelStartIndex; + for(int i = count - 1; i > 1; --i) { int randomNum = Math::Rand() % (i+1); - int t = __pShuffledList[randomNum]; + int shuffleIndex = __pShuffledList[randomNum]; __pShuffledList[randomNum] = __pShuffledList[i]; - __pShuffledList[i] = t; + __pShuffledList[i] = shuffleIndex; + + if(shuffleIndex == origIndex) + { + curPos = i; + } } + + if(origIndex != __pShuffledList[__shuffelStartIndex]) + { + int tempIndex = __pShuffledList[__shuffelStartIndex]; + __pShuffledList[__shuffelStartIndex] = origIndex; + __pShuffledList[curPos] = tempIndex; + } + AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult())); } -- 2.7.4