[vlc-commits] [Git][videolan/vlc][master] 2 commits: diffutil: fix bad index on successive aggregate insertions

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Apr 24 22:45:57 UTC 2022



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
0cf698e1 by Pierre Lamot at 2022-04-24T22:32:09+00:00
diffutil: fix bad index on successive aggregate insertions

in a scenario "____" => "__AA__AA", the index of second insertion was erroneous

- - - - -
3ee0fd64 by Pierre Lamot at 2022-04-24T22:32:09+00:00
qt: fix out of bound in MLListcache during remove operations

the removed data are after the m_partialIndex in the old model so the partial
index should not be placed after.

fix: #26848

- - - - -


3 changed files:

- modules/gui/qt/medialibrary/mllistcache.cpp
- src/misc/diffutil.c
- src/test/diffutil.c


Changes:

=====================================
modules/gui/qt/medialibrary/mllistcache.cpp
=====================================
@@ -354,11 +354,10 @@ void MLListCache::partialUpdate()
             break;
         case VLC_DIFFUTIL_OP_REMOVE:
             m_partialX = op.op.remove.x;
-            m_partialIndex = op.op.remove.index + op.count - 1;
+            m_partialIndex = op.op.remove.index;
             emit beginRemoveRows(op.op.remove.index, op.op.remove.index + op.count - 1);
             m_partialLoadedCount -= op.count;
             m_partialX += op.count;
-            m_partialIndex = op.op.remove.index + 1;
             partialTotalCount -= op.count;
             emit endRemoveRows();
             emit localSizeChanged(partialTotalCount);


=====================================
src/misc/diffutil.c
=====================================
@@ -379,6 +379,7 @@ static void buildResultInsert(void* cbData, const void* listOld, uint32_t oldPos
         if (previousOp->type == VLC_DIFFUTIL_OP_INSERT
             && previousOp->op.insert.y + previousOp->count == newPos)
         {
+            ctx->head++;
             previousOp->count += 1;
             return;
         }


=====================================
src/test/diffutil.c
=====================================
@@ -221,8 +221,11 @@ int main()
 
     CHECK_SIMPLE("____", "__AA__", {'+', 2, "A"}, {'+', 3, "A"});
     CHECK_SIMPLE("____", "__A_A_", {'+', 2, "A"}, {'+', 4, "A"});
+    CHECK_SIMPLE("__", "A__A", {'+', 0, "A"}, {'+', 3, "A"});
+    CHECK_SIMPLE("____", "AA____AA", {'+', 0, "A"}, {'+', 1, "A"}, {'+', 6, "A"}, {'+', 7, "A"});
     CHECK_SIMPLE("__DD__", "____", {'-', 2, "D"}, {'-', 2, "D"});
     CHECK_SIMPLE("__D_D_", "____", {'-', 2, "D"}, {'-', 3, "D"});
+    CHECK_SIMPLE("D__D", "__", {'-', 0, "D"}, {'-', 2, "D"});
     CHECK_SIMPLE("__DD__", "__A__", {'-', 2, "D"}, {'-', 2, "D"}, {'+', 2, "A"});
     CHECK_SIMPLE("__DD____", "____A__", {'-', 2, "D"}, {'-', 2, "D"}, {'+', 4, "A"});
     CHECK_SIMPLE("____DD__", "__A____", {'+', 2, "A"}, {'-', 5, "D"}, {'-', 5, "D"});
@@ -236,11 +239,17 @@ int main()
     CHECK_AGGREG("DDDD", "AAA", {'-', 0, "DDDD"}, {'+', 0, "AAA"});
     CHECK_AGGREG("____", "__AA__", {'+', 2, "AA"});
     CHECK_AGGREG("____", "__A_A_", {'+', 2, "A"}, {'+', 4, "A"});
+    CHECK_AGGREG("____", "AA____AA", {'+', 0, "AA"}, {'+', 6, "AA"});
+    CHECK_AGGREG("____", "AA__AA__AA", {'+', 0, "AA"}, {'+', 4, "AA"}, {'+', 8, "AA"});
     CHECK_AGGREG("__DD__", "____", {'-', 2, "DD"});
     CHECK_AGGREG("__D_D_", "____", {'-', 2, "D"}, {'-', 3, "D"});
+    CHECK_AGGREG("DD____DD", "____", {'-', 0, "DD"}, {'-', 4, "DD"});
+    CHECK_AGGREG("DD__DD__DD", "____", {'-', 0, "DD"}, {'-', 2, "DD"}, {'-', 4, "DD"});
     CHECK_AGGREG("__DD__", "__A__", {'-', 2, "DD"}, {'+', 2, "A"});
     CHECK_AGGREG("__DD____", "____A__", {'-', 2, "DD"}, {'+', 4, "A"});
     CHECK_AGGREG("____DD__", "__A____", {'+', 2, "A"}, {'-', 5, "DD"});
+    CHECK_AGGREG("__DD__", "AA____AA", {'+', 0, "AA"}, {'-', 4, "DD"}, {'+', 6, "AA"});
+    CHECK_AGGREG("DD____DD", "__AA__", {'-', 0, "DD"}, {'+', 2, "AA"}, {'-', 6, "DD"});
 
 
     //move forward
@@ -282,6 +291,12 @@ int main()
     CHECK_MOVE_AG("__DD__", "__A__", {'-', 2, "DD"}, {'+', 2, "A"});
     CHECK_MOVE_AG("__DD____", "____A__", {'-', 2, "DD"}, {'+', 4, "A"});
     CHECK_MOVE_AG("____DD__", "__A____", {'+', 2, "A"}, {'-', 5, "DD"});
+    CHECK_MOVE_AG("____", "AA____AA", {'+', 0, "AA"}, {'+', 6, "AA"});
+    CHECK_MOVE_AG("____", "AA__AA__AA", {'+', 0, "AA"}, {'+', 4, "AA"}, {'+', 8, "AA"});
+    CHECK_MOVE_AG("DD____DD", "____", {'-', 0, "DD"}, {'-', 4, "DD"});
+    CHECK_MOVE_AG("DD__DD__DD", "____", {'-', 0, "DD"}, {'-', 2, "DD"}, {'-', 4, "DD"});
+    CHECK_MOVE_AG("__DD__", "AA____AA", {'+', 0, "AA"}, {'-', 4, "DD"}, {'+', 6, "AA"});
+    CHECK_MOVE_AG("DD____DD", "__AA__", {'-', 0, "DD"}, {'+', 2, "AA"}, {'-', 6, "DD"});
 
     CHECK_MOVE_AG("_123______", "______123_", {'m', CHECK_MOVE_PACK(1, 9), "123"});
     CHECK_MOVE_AG("______123_", "_123______", {'m', CHECK_MOVE_PACK(6, 1), "123"});



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2814f8e27de87ef1ada81c01cf8957f1620970fc...3ee0fd64f00bdc5b2cd5d5422989407d0665f73d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2814f8e27de87ef1ada81c01cf8957f1620970fc...3ee0fd64f00bdc5b2cd5d5422989407d0665f73d
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list