diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-08 15:01:01 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-08 15:01:01 +0100 |
commit | 8e00e0056e3c3dfdb35206ba5061a647d821edce (patch) | |
tree | 2bb0ed3159e978e885b0be79cc185d260e93545a /sw | |
parent | df87cec5ad59605d057ade2a0203e590d2aadc8d (diff) |
coverity#1257107: handle these consistently
Change-Id: I5f432eea235bdca05132cf553d9bc15e2b825509
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/crsr/viscrs.cxx | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 80af294252ef..13bbd29a7950 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -538,8 +538,12 @@ void SwShellCrsr::FillRects() void SwShellCrsr::Show() { - for(SwPaM& rTmp : GetRingContainer()) - dynamic_cast<SwShellCrsr&>(rTmp).SwSelPaintRects::Show(); + for(SwPaM& rPaM : GetRingContainer()) + { + SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rPaM); + if(pShCrsr) + pShCrsr->SwSelPaintRects::Show(); + } } // This rectangle gets painted anew, therefore the SSelection in this @@ -558,13 +562,12 @@ void SwShellCrsr::Invalidate( const SwRect& rRect ) void SwShellCrsr::Hide() { - SwShellCrsr * pTmp = this; - // TODO: this doesnt look sane: if the dynamic_cast ever returns a nullptr, - // the next pTmp->GetNext() call is a nullptr deref - do { - if (pTmp) - pTmp->SwSelPaintRects::Hide(); - } while( this != ( pTmp = dynamic_cast<SwShellCrsr*>(pTmp->GetNext()) ) ); + for(SwPaM& rPaM : GetRingContainer()) + { + SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rPaM); + if(pShCrsr) + pShCrsr->SwSelPaintRects::Hide(); + } } SwCursor* SwShellCrsr::Create( SwPaM* pRing ) const |