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

Vasily Melenchuk (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 14 15:43:12 UTC 2019


 sw/source/core/inc/UndoCore.hxx |    1 -
 sw/source/core/undo/unfmco.cxx  |   12 +++---------
 2 files changed, 3 insertions(+), 10 deletions(-)

New commits:
commit 488979e8aea3acaefe84d5e86e481751eb176749
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Thu Aug 1 12:15:45 2019 +0300
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Aug 14 17:42:22 2019 +0200

    sw: undo/redo dangling pointer removed
    
    pFormatColl can be invalidated if it refers style previously
    removed/created during undo/redo. So instead of keeping pointer
    let's use style name.
    
    Change-Id: I79c5a92046134c1921c9245f78335c8f033b05fb
    Reviewed-on: https://gerrit.libreoffice.org/76781
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    (cherry picked from commit d2750b7eb02d6f1c8866199c98fe2e2286639b88)
    Reviewed-on: https://gerrit.libreoffice.org/77423
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx
index 1699c5716041..6a2d9289b50b 100644
--- a/sw/source/core/inc/UndoCore.hxx
+++ b/sw/source/core/inc/UndoCore.hxx
@@ -145,7 +145,6 @@ class SwUndoFormatColl : public SwUndo, private SwUndRng
 {
     OUString aFormatName;
     std::unique_ptr<SwHistory> pHistory;
-    SwFormatColl* const pFormatColl;
     // for correct <ReDo(..)> and <Repeat(..)>
     // boolean, which indicates that the attributes are reset at the nodes
     // before the format has been applied.
diff --git a/sw/source/core/undo/unfmco.cxx b/sw/source/core/undo/unfmco.cxx
index 7fe9b244146b..b56aebe7f41d 100644
--- a/sw/source/core/undo/unfmco.cxx
+++ b/sw/source/core/undo/unfmco.cxx
@@ -32,7 +32,6 @@ SwUndoFormatColl::SwUndoFormatColl( const SwPaM& rRange,
     : SwUndo( SwUndoId::SETFMTCOLL, rRange.GetDoc() ),
       SwUndRng( rRange ),
       pHistory( new SwHistory ),
-      pFormatColl( pColl ),
       mbReset( bReset ),
       mbResetListAttrs( bResetListAttrs )
 {
@@ -71,12 +70,10 @@ void SwUndoFormatColl::DoSetFormatColl(SwDoc & rDoc, SwPaM const & rPaM)
 {
     // Only one TextFrameColl can be applied to a section, thus request only in
     // this array.
-
-    // does the format still exist?
-    if (rDoc.GetTextFormatColls()->IsAlive(static_cast<SwTextFormatColl*>(pFormatColl)))
+    SwTextFormatColl * pFormatColl = rDoc.FindTextFormatCollByName(aFormatName);
+    if (pFormatColl)
     {
-        rDoc.SetTextFormatColl(rPaM, static_cast<SwTextFormatColl*>(pFormatColl), mbReset,
-                           mbResetListAttrs);
+        rDoc.SetTextFormatColl(rPaM, pFormatColl, mbReset, mbResetListAttrs);
     }
 }
 
@@ -84,9 +81,6 @@ SwRewriter SwUndoFormatColl::GetRewriter() const
 {
     SwRewriter aResult;
 
-    // #i31191# Use stored format name instead of
-    // pFormatColl->GetName(), because pFormatColl does not have to be available
-    // anymore.
     aResult.AddRule(UndoArg1, aFormatName );
 
     return aResult;


More information about the Libreoffice-commits mailing list