Fixed issue 35692
authorchitta ranjan <chitta.rs@samsung.com>
Mon, 22 Apr 2013 09:18:47 +0000 (18:18 +0900)
committerchitta ranjan <chitta.rs@samsung.com>
Mon, 22 Apr 2013 09:18:47 +0000 (18:18 +0900)
Change-Id: If5e0b1ac61ffc398fad3d908fed9f54de054fac1
Signed-off-by: chitta ranjan <chitta.rs@samsung.com>
src/IvImageViewerForm.cpp

index c396fcf..dfb5249 100644 (file)
@@ -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()));
 }