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

Vasily Melenchuk (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 6 09:33:16 UTC 2019


 sw/source/core/inc/UndoCore.hxx |    4 ++--
 sw/source/core/undo/undobj1.cxx |   21 +++++++++++----------
 2 files changed, 13 insertions(+), 12 deletions(-)

New commits:
commit 3d3a0979fa148ab90d6794f58829f2c3cd90503a
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Fri Jul 26 10:45:59 2019 +0300
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Aug 6 11:32:35 2019 +0200

    tdf#126168: sw undo/redo crash fixed
    
    After undo of style creation we have a dangling pointers to
    deleted style in SwUndoSetFlyFormat. So instead of keeping
    pointers to SwFrameFormat which can be invalidated, we could
    keep style name and find style by name.
    
    Reviewed-on: https://gerrit.libreoffice.org/76351
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Tested-by: Jenkins
    (cherry picked from commit 20e7632919f4bbefabb4190d10ee79c65b89dca7)
    Reviewed-on: https://gerrit.libreoffice.org/76798
    Reviewed-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    
    Change-Id: I9a60d6b3311278d7391d676010c31c862189fd08
    Reviewed-on: https://gerrit.libreoffice.org/76857
    Tested-by: Jenkins
    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 d5b7c2561141..16277759486f 100644
--- a/sw/source/core/inc/UndoCore.hxx
+++ b/sw/source/core/inc/UndoCore.hxx
@@ -189,8 +189,8 @@ public:
 class SwUndoSetFlyFormat : public SwUndo, public SwClient
 {
     SwFrameFormat* pFrameFormat;                  // saved FlyFormat
-    SwFrameFormat* const pOldFormat;
-    SwFrameFormat* pNewFormat;
+    const OUString m_DerivedFromFormatName;
+    const OUString m_NewFormatName;
     std::unique_ptr<SfxItemSet> pItemSet;               // the re-/ set attributes
     sal_uLong nOldNode, nNewNode;
     sal_Int32 nOldContent, nNewContent;
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 763b2ed5b221..eab00fcd3e31 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -456,7 +456,8 @@ void SwUndoDelLayFormat::RedoForRollback()
 
 SwUndoSetFlyFormat::SwUndoSetFlyFormat( SwFrameFormat& rFlyFormat, SwFrameFormat& rNewFrameFormat )
     : SwUndo( SwUndoId::SETFLYFRMFMT, rFlyFormat.GetDoc() ), SwClient( &rFlyFormat ), pFrameFormat( &rFlyFormat ),
-    pOldFormat( static_cast<SwFrameFormat*>(rFlyFormat.DerivedFrom()) ), pNewFormat( &rNewFrameFormat ),
+    m_DerivedFromFormatName( rFlyFormat.IsDefault() ? "" : rFlyFormat.DerivedFrom()->GetName() ),
+    m_NewFormatName( rNewFrameFormat.GetName() ),
     pItemSet( new SfxItemSet( *rFlyFormat.GetAttrSet().GetPool(),
                                 rFlyFormat.GetAttrSet().GetRanges() )),
     nOldNode( 0 ), nNewNode( 0 ),
@@ -469,8 +470,7 @@ SwRewriter SwUndoSetFlyFormat::GetRewriter() const
 {
     SwRewriter aRewriter;
 
-    if (pNewFormat)
-        aRewriter.AddRule(UndoArg1, pNewFormat->GetName());
+    aRewriter.AddRule(UndoArg1, m_NewFormatName);
 
     return aRewriter;
 }
@@ -531,13 +531,14 @@ void SwUndoSetFlyFormat::UndoImpl(::sw::UndoRedoContext & rContext)
     SwDoc & rDoc = rContext.GetDoc();
 
     // Is the new Format still existent?
-    if (rDoc.GetFrameFormats()->IsAlive(pOldFormat))
+    SwFrameFormat* pDerivedFromFrameFormat = rDoc.FindFrameFormatByName(m_DerivedFromFormatName);
+    if (pDerivedFromFrameFormat)
     {
         if( bAnchorChgd )
             pFrameFormat->DelFrames();
 
-        if( pFrameFormat->DerivedFrom() != pOldFormat )
-            pFrameFormat->SetDerivedFrom( pOldFormat );
+        if( pFrameFormat->DerivedFrom() != pDerivedFromFrameFormat )
+            pFrameFormat->SetDerivedFrom( pDerivedFromFrameFormat );
 
         SfxItemIter aIter( *pItemSet );
         const SfxPoolItem* pItem = aIter.GetCurItem();
@@ -605,19 +606,19 @@ void SwUndoSetFlyFormat::RedoImpl(::sw::UndoRedoContext & rContext)
     SwDoc & rDoc = rContext.GetDoc();
 
     // Is the new Format still existent?
-    if (rDoc.GetFrameFormats()->IsAlive(pNewFormat))
+    SwFrameFormat* pNewFrameFormat = rDoc.FindFrameFormatByName(m_NewFormatName);
+    if (pNewFrameFormat)
     {
-
         if( bAnchorChgd )
         {
             SwFormatAnchor aNewAnchor( nNewAnchorTyp );
             GetAnchor( aNewAnchor, nNewNode, nNewContent );
             SfxItemSet aSet( rDoc.GetAttrPool(), aFrameFormatSetRange );
             aSet.Put( aNewAnchor );
-            rDoc.SetFrameFormatToFly( *pFrameFormat, *pNewFormat, &aSet );
+            rDoc.SetFrameFormatToFly( *pFrameFormat, *pNewFrameFormat, &aSet );
         }
         else
-            rDoc.SetFrameFormatToFly( *pFrameFormat, *pNewFormat );
+            rDoc.SetFrameFormatToFly( *pFrameFormat, *pNewFrameFormat );
 
         rContext.SetSelections(pFrameFormat, nullptr);
     }


More information about the Libreoffice-commits mailing list