[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sw/source

Michael Stahl mstahl at redhat.com
Fri Aug 11 16:17:58 UTC 2017


 sw/source/core/txtnode/ndtxt.cxx |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit 3a54c06ff6f7367fe35b7509cc266d60498e3440
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Aug 11 10:58:43 2017 +0200

    tdf#105705 sw: fix another case of bookmarks becoming un-sorted
    
    The loop in SwTextNode::Update() that reassigns bookmark end positions
    away from the node to a temporary SwIndexReg can stop prematurely in a
    particular situation where there is a bookmark that is expanded and with
    both mark positions at the critical "rPos" insertion position, and also
    both their SwIndexes consecutive in the SwIndexReg::m_pFirst
    linked-list.
    
    What happens then is that the iteration gets to the first of the 2
    consecutive positions of the bookmark, then calls GetMarkEnd() on the
    mark, which happens to return the other position, which is already
    stored in the "next" local variable.
    
    That other position is then moved to aTmpIdxReg, and in the next loop
    iteration GetNext() is null as it is the last one in aTmpIdxReg and the
    loop terminates.
    
    Thus various bookmark end positions don't get preserved, or the
    bAtLeastOneExpandedBookmarkAtInsertionPosition doesn't get set, either
    of which can cause the bookmark array to lose its sort order.
    
    This was found playing around with Zotero 4.0.29.10, while switching
    between different citation styles.
    
    (regression from 6a5dbe73537642b06bcde782118a34b4593d17eb)
    
    Change-Id: Ia35ce0656bcb2d6af7ea189458af3942ff83e4da
    (cherry picked from commit f78aadea74b99ba71f930c7cf52352da9ee965e9)
    Reviewed-on: https://gerrit.libreoffice.org/41016
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 5e78fc0abd7b..9cc9b58c6be0 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1090,6 +1090,10 @@ void SwTextNode::Update(
                 if( this == &pEnd->nNode.GetNode() &&
                     rPos.GetIndex() == rEndIdx.GetIndex() )
                 {
+                    if (&rEndIdx == next) // nasty corner case:
+                    {   // don't switch to iterating aTmpIdxReg!
+                        next = rEndIdx.GetNext();
+                    }
                     rEndIdx.Assign( &aTmpIdxReg, rEndIdx.GetIndex() );
                     bAtLeastOneBookmarkMoved = true;
                 }


More information about the Libreoffice-commits mailing list