From 8e00e0056e3c3dfdb35206ba5061a647d821edce Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Mon, 8 Dec 2014 15:01:01 +0100 Subject: coverity#1257107: handle these consistently Change-Id: I5f432eea235bdca05132cf553d9bc15e2b825509 --- sw/source/core/crsr/viscrs.cxx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'sw') 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(rTmp).SwSelPaintRects::Show(); + for(SwPaM& rPaM : GetRingContainer()) + { + SwShellCrsr* pShCrsr = dynamic_cast(&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(pTmp->GetNext()) ) ); + for(SwPaM& rPaM : GetRingContainer()) + { + SwShellCrsr* pShCrsr = dynamic_cast(&rPaM); + if(pShCrsr) + pShCrsr->SwSelPaintRects::Hide(); + } } SwCursor* SwShellCrsr::Create( SwPaM* pRing ) const -- cgit