summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2017-04-27 18:07:54 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-04-27 22:29:10 +0200
commit1df637bde32c484b681ecdfebf56fdca03db7fc1 (patch)
treef4a9927217fc0b6fc81c95c5a66c15b09c1b5fde
parent91a1342aa2930268006614680ec439c6ebecdedb (diff)
tdf#88555: band-aid fix, using GetPos/find instead of Contains
to find out whether given format still exists. GetPos was replaced by Contains on multiple places in commit 98436c4b53639d86f261ac630c46d32e3c7b8e28 but sometimes after series of undos/redos, vtable of some items in those format arrays becomes corrupt and it makes dynamic_cast (as used by Contains) fail and Writer falls flat on its face. This is just a workaround, no idea about the root cause. Change-Id: I1e02fd932dbac741687c15900841b9b7c778e2d4 Reviewed-on: https://gerrit.libreoffice.org/37038 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--sw/source/core/undo/unattr.cxx22
-rw-r--r--sw/source/core/undo/unfmco.cxx2
2 files changed, 12 insertions, 12 deletions
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index d97b3953ced9..9805ed309dd9 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -200,21 +200,21 @@ bool SwUndoFormatAttr::IsFormatInDoc( SwDoc* pDoc )
{
// search for the Format in the Document; if it does not exist any more,
// the attribute is not restored!
- bool bFound = false;
+ size_t nPos = SIZE_MAX;
switch ( m_nFormatWhich )
{
case RES_TXTFMTCOLL:
case RES_CONDTXTFMTCOLL:
- bFound = pDoc->GetTextFormatColls()->Contains( m_pFormat );
+ nPos = pDoc->GetTextFormatColls()->GetPos( m_pFormat );
break;
case RES_GRFFMTCOLL:
- bFound = pDoc->GetGrfFormatColls()->Contains(
+ nPos = pDoc->GetGrfFormatColls()->GetPos(
static_cast<const SwGrfFormatColl*>(m_pFormat) );
break;
case RES_CHRFMT:
- bFound = pDoc->GetCharFormats()->Contains( m_pFormat );
+ nPos = pDoc->GetCharFormats()->GetPos( m_pFormat );
break;
case RES_FRMFMT:
@@ -225,14 +225,14 @@ bool SwUndoFormatAttr::IsFormatInDoc( SwDoc* pDoc )
{
m_pFormat =
static_cast<SwTableNode*>(pNd)->GetTable().GetFrameFormat();
- bFound = true;
+ nPos = 0;
break;
}
else if ( pNd->IsSectionNode() )
{
m_pFormat =
static_cast<SwSectionNode*>(pNd)->GetSection().GetFormat();
- bFound = true;
+ nPos = 0;
break;
}
else if ( pNd->IsStartNode() && (SwTableBoxStartNode ==
@@ -246,7 +246,7 @@ bool SwUndoFormatAttr::IsFormatInDoc( SwDoc* pDoc )
if ( pBox )
{
m_pFormat = pBox->GetFrameFormat();
- bFound = true;
+ nPos = 0;
break;
}
}
@@ -255,13 +255,13 @@ bool SwUndoFormatAttr::IsFormatInDoc( SwDoc* pDoc )
SAL_FALLTHROUGH;
case RES_DRAWFRMFMT:
case RES_FLYFRMFMT:
- if (pDoc->GetSpzFrameFormats()->Contains( m_pFormat )
- || pDoc->GetFrameFormats()->Contains( m_pFormat ))
- bFound = true;
+ if ( ( pDoc->GetSpzFrameFormats()->find( static_cast<SwFrameFormat*>(m_pFormat) ) != pDoc->GetSpzFrameFormats()->end() )
+ || ( pDoc->GetFrameFormats()->find( static_cast<SwFrameFormat*>( m_pFormat ) ) != pDoc->GetFrameFormats()->end() ) )
+ nPos = 0;
break;
}
- if ( !bFound )
+ if ( nPos == SIZE_MAX )
{
// Format does not exist; reset
m_pFormat = nullptr;
diff --git a/sw/source/core/undo/unfmco.cxx b/sw/source/core/undo/unfmco.cxx
index bc506d79c794..aa55ba045ca0 100644
--- a/sw/source/core/undo/unfmco.cxx
+++ b/sw/source/core/undo/unfmco.cxx
@@ -73,7 +73,7 @@ void SwUndoFormatColl::DoSetFormatColl(SwDoc & rDoc, SwPaM & rPaM)
// this array.
// does the format still exist?
- if( rDoc.GetTextFormatColls()->Contains(static_cast<SwTextFormatColl*>(pFormatColl)) )
+ if( SIZE_MAX != rDoc.GetTextFormatColls()->GetPos(static_cast<SwTextFormatColl*>(pFormatColl)) )
{
rDoc.SetTextFormatColl(rPaM, static_cast<SwTextFormatColl*>(pFormatColl), mbReset,
mbResetListAttrs);