summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2019-08-01 12:15:45 +0300
committerMichael Stahl <Michael.Stahl@cib.de>2019-08-14 17:42:22 +0200
commit488979e8aea3acaefe84d5e86e481751eb176749 (patch)
tree6cc2a7fe71396d215d67d41e038b8dc4cf9441d8
parentbd4f9c7c77a28db3a927faa6cc63e02015b65e76 (diff)
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@CIB.de> (cherry picked from commit d2750b7eb02d6f1c8866199c98fe2e2286639b88) Reviewed-on: https://gerrit.libreoffice.org/77423 Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r--sw/source/core/inc/UndoCore.hxx1
-rw-r--r--sw/source/core/undo/unfmco.cxx12
2 files changed, 3 insertions, 10 deletions
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;