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

Vasily Melenchuk (via logerrit) logerrit at kemper.freedesktop.org
Fri Aug 2 09:26:37 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 9b9a69aa0eefca90ed4a72caae97b485aabb37ae
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Fri Jul 26 10:45:59 2019 +0300
Commit:     Xisco FaulĂ­ <xiscofauli at libreoffice.org>
CommitDate: Fri Aug 2 11:25:57 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.
    
    Change-Id: I9a60d6b3311278d7391d676010c31c862189fd08
    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>

diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx
index 002f2ebc1b2d..1699c5716041 100644
--- a/sw/source/core/inc/UndoCore.hxx
+++ b/sw/source/core/inc/UndoCore.hxx
@@ -188,8 +188,8 @@ public:
 class SwUndoSetFlyFormat : public SwUndo, public SwClient
 {
     SwFrameFormat* m_pFrameFormat;                  // saved FlyFormat
-    SwFrameFormat* const m_pOldFormat;
-    SwFrameFormat* m_pNewFormat;
+    const OUString m_DerivedFromFormatName;
+    const OUString m_NewFormatName;
     std::unique_ptr<SfxItemSet> m_pItemSet;               // the re-/ set attributes
     sal_uLong m_nOldNode, m_nNewNode;
     sal_Int32 m_nOldContent, m_nNewContent;
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index f88611b0cf11..6a2387f8712f 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -457,7 +457,8 @@ void SwUndoDelLayFormat::RedoForRollback()
 
 SwUndoSetFlyFormat::SwUndoSetFlyFormat( SwFrameFormat& rFlyFormat, SwFrameFormat& rNewFrameFormat )
     : SwUndo( SwUndoId::SETFLYFRMFMT, rFlyFormat.GetDoc() ), SwClient( &rFlyFormat ), m_pFrameFormat( &rFlyFormat ),
-    m_pOldFormat( static_cast<SwFrameFormat*>(rFlyFormat.DerivedFrom()) ), m_pNewFormat( &rNewFrameFormat ),
+    m_DerivedFromFormatName( rFlyFormat.IsDefault() ? "" : rFlyFormat.DerivedFrom()->GetName() ),
+    m_NewFormatName( rNewFrameFormat.GetName() ),
     m_pItemSet( new SfxItemSet( *rFlyFormat.GetAttrSet().GetPool(),
                                 rFlyFormat.GetAttrSet().GetRanges() )),
     m_nOldNode( 0 ), m_nNewNode( 0 ),
@@ -470,8 +471,7 @@ SwRewriter SwUndoSetFlyFormat::GetRewriter() const
 {
     SwRewriter aRewriter;
 
-    if (m_pNewFormat)
-        aRewriter.AddRule(UndoArg1, m_pNewFormat->GetName());
+    aRewriter.AddRule(UndoArg1, m_NewFormatName);
 
     return aRewriter;
 }
@@ -532,13 +532,14 @@ void SwUndoSetFlyFormat::UndoImpl(::sw::UndoRedoContext & rContext)
     SwDoc & rDoc = rContext.GetDoc();
 
     // Is the new Format still existent?
-    if (rDoc.GetFrameFormats()->IsAlive(m_pOldFormat))
+    SwFrameFormat* pDerivedFromFrameFormat = rDoc.FindFrameFormatByName(m_DerivedFromFormatName);
+    if (pDerivedFromFrameFormat)
     {
         if( m_bAnchorChanged )
             m_pFrameFormat->DelFrames();
 
-        if( m_pFrameFormat->DerivedFrom() != m_pOldFormat )
-            m_pFrameFormat->SetDerivedFrom( m_pOldFormat );
+        if( m_pFrameFormat->DerivedFrom() != pDerivedFromFrameFormat)
+            m_pFrameFormat->SetDerivedFrom(pDerivedFromFrameFormat);
 
         SfxItemIter aIter( *m_pItemSet );
         const SfxPoolItem* pItem = aIter.GetCurItem();
@@ -606,19 +607,19 @@ void SwUndoSetFlyFormat::RedoImpl(::sw::UndoRedoContext & rContext)
     SwDoc & rDoc = rContext.GetDoc();
 
     // Is the new Format still existent?
-    if (rDoc.GetFrameFormats()->IsAlive(m_pNewFormat))
+    SwFrameFormat* pNewFrameFormat = rDoc.FindFrameFormatByName(m_NewFormatName);
+    if (pNewFrameFormat)
     {
-
         if( m_bAnchorChanged )
         {
             SwFormatAnchor aNewAnchor( m_nNewAnchorType );
             GetAnchor( aNewAnchor, m_nNewNode, m_nNewContent );
             SfxItemSet aSet( rDoc.GetAttrPool(), aFrameFormatSetRange );
             aSet.Put( aNewAnchor );
-            rDoc.SetFrameFormatToFly( *m_pFrameFormat, *m_pNewFormat, &aSet );
+            rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat, &aSet );
         }
         else
-            rDoc.SetFrameFormatToFly( *m_pFrameFormat, *m_pNewFormat );
+            rDoc.SetFrameFormatToFly( *m_pFrameFormat, *pNewFrameFormat);
 
         rContext.SetSelections(m_pFrameFormat, nullptr);
     }


More information about the Libreoffice-commits mailing list