diff options
-rw-r--r-- | sw/inc/doc.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 6 |
3 files changed, 9 insertions, 1 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index b5028561fb66..17f0ce4ea36f 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -248,6 +248,7 @@ class SW_DLLPUBLIC SwDoc final std::unique_ptr<sw::FrameFormats<SwFrameFormat*>> mpFrameFormatTable; //< Format table std::unique_ptr<SwCharFormats> mpCharFormatTable; + std::unique_ptr<SwCharFormats> mpCharFormatDeletionTable; std::unique_ptr<sw::FrameFormats<sw::SpzFrameFormat*>> mpSpzFrameFormatTable; std::unique_ptr<SwSectionFormats> mpSectionFormatTable; std::unique_ptr<sw::TableFrameFormats> mpTableFrameFormatTable; //< For tables diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 3390a506052c..755ee2541fde 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -691,7 +691,8 @@ void SwDoc::DelCharFormat(size_t nFormat, bool bBroadcast) std::make_unique<SwUndoCharFormatDelete>(pDel, *this)); } - delete (*mpCharFormatTable)[nFormat]; + // tdf#140061 keep SwCharFormat instances alive while SwDoc is alive + mpCharFormatDeletionTable->insert(pDel); mpCharFormatTable->erase(mpCharFormatTable->begin() + nFormat); getIDocumentState().SetModified(); diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index d6e885e8219a..3c1adbd3012e 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -234,6 +234,7 @@ SwDoc::SwDoc() mpDfltGrfFormatColl( new SwGrfFormatColl( GetAttrPool(), "Graphikformatvorlage" ) ), mpFrameFormatTable( new sw::FrameFormats<SwFrameFormat*>() ), mpCharFormatTable( new SwCharFormats ), + mpCharFormatDeletionTable( new SwCharFormats ), mpSpzFrameFormatTable( new sw::FrameFormats<sw::SpzFrameFormat*>() ), mpSectionFormatTable( new SwSectionFormats ), mpTableFrameFormatTable( new sw::TableFrameFormats() ), @@ -591,6 +592,10 @@ SwDoc::~SwDoc() mpStyleAccess.reset(); mpCharFormatTable.reset(); + // tdf#140061 keep SwCharFormat instances alive while SwDoc is alive + if (mpCharFormatDeletionTable) + mpCharFormatDeletionTable->DeleteAndDestroyAll(/*keepDefault*/false); + mpCharFormatDeletionTable.reset(); mpSectionFormatTable.reset(); mpTableFrameFormatTable.reset(); mpDfltTextFormatColl.reset(); @@ -745,6 +750,7 @@ void SwDoc::ClearDoc() mpTextFormatCollTable->DeleteAndDestroy(1, mpTextFormatCollTable->size()); mpGrfFormatCollTable->DeleteAndDestroy(1, mpGrfFormatCollTable->size()); mpCharFormatTable->DeleteAndDestroyAll(/*keepDefault*/true); + mpCharFormatDeletionTable->DeleteAndDestroyAll(/*keepDefault*/false); if( getIDocumentLayoutAccess().GetCurrentViewShell() ) { |