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

Michael Stahl mstahl at redhat.com
Wed Jan 21 07:36:59 PST 2015


 sw/source/core/txtnode/txtedt.cxx |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

New commits:
commit 2ab8f8e2baaeaa57068942ec6844e3033e5f2966
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jan 21 11:12:34 2015 +0100

    sw: fix bogus assert in SwTxtNode::RstTxtAttr()
    
    The assert for case 3 is wrong and fires when importing ooo44732-2.doc
    but there is also a bug here where a hint could be skipped.
    
    Change-Id: I028d2d5df9e80cf0001d9bc11aa7fabcd01e83bb
    (cherry picked from commit 01d25c96db366de003e4570ddf8559da3dd9ea5b)
    Reviewed-on: https://gerrit.libreoffice.org/14072
    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/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 58164c6..55b5c91 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -529,6 +529,7 @@ void SwTxtNode::RstTxtAttr(
                 }
                 else    // Case: 3
                 {
+                    bChanged = true;
                     m_pSwpHints->NoteInHistory( pHt );
                     // UGLY: this may temporarily destroy the sorting!
                     pHt->GetStart() = nEnd;
@@ -539,13 +540,19 @@ void SwTxtNode::RstTxtAttr(
                         SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(),
                                 *pStyleHandle, nAttrStart, nEnd );
                         InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST );
-                    }
-
-                    // this case appears to rely on InsertHint not re-sorting
-                    // and pNew being inserted behind pHt
-                    assert(pHt == m_pSwpHints->GetTextHint(i));
 
-                    bChanged = true;
+                        // skip the ++i because InsertHint will re-sort
+                        // so now an unrelated hint (previous i+1) may be at i!
+                        // (but pHt and pNew can only move to indexes >= i)
+#if OSL_DEBUG_LEVEL > 0
+                        for (size_t j = 0; j < i; ++j)
+                        {
+                            assert(m_pSwpHints->GetTextHint(j) != pHt);
+                            assert(m_pSwpHints->GetTextHint(j) != pNew);
+                        }
+#endif
+                        continue;
+                    }
                 }
             }
         }


More information about the Libreoffice-commits mailing list