Menu

TBaseList.Move bug

Help
2014-05-07
2015-01-11
  • Alexandre Guilleme

    This function doesn't work properly.
    For example, with a TIntegerList [0, 1, 2, 3, 4], a call to TIntegerList.Move(4, 0) should produce [4, 0, 1, 2, 3], but the result obtained is [4, 0, 1, 2, 4]

    Here is a patch to fix it :

    Index: VectorLists.pas
    ===================================================================
    --- VectorLists.pas (révision 6451)
    +++ VectorLists.pas (copie de travail)
    @@ -1198,13 +1198,13 @@
         begin
           // curIndex+1 necessarily exists since curIndex<newIndex and newIndex<Count
           System.Move(FBaseList[(curIndex + 1) * FItemSize], FBaseList[curIndex * FItemSize],
    -        (newIndex - curIndex - 1) * FItemSize);
    +        (newIndex - curIndex) * FItemSize);
         end
         else
         begin
           // newIndex+1 necessarily exists since newIndex<curIndex and curIndex<Count
           System.Move(FBaseList[newIndex * FItemSize], FBaseList[(newIndex + 1) * FItemSize],
    -        (curIndex - newIndex - 1) * FItemSize);
    +        (curIndex - newIndex) * FItemSize);
         end;
         if FItemSize = 4 then
           PInteger(@FBaseList[newIndex * FItemSize])^ := PInteger(BufferItem)^
    
     
  • Pavel Vassiliev

    Pavel Vassiliev - 2015-01-11

    Alexandre,
    Thanks for finding but could you give an example when and how it appears in your demos? Or explain consequences in more details. I'll fix it.
    PW

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.