From 142dc93d9ad793e036baa5573aea31cb6f416f57 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 26 Oct 2020 16:41:29 +0100 Subject: [PATCH] (related: tdf#131679) sw: only unmark if this SwFlyFrame is marked Seems kind of pointless to unmark flys that aren't deleted. SwFEShell::SelectObj() apparently guarantees that at most 1 SwFlyFrame is marked. Change-Id: I061fc640512192e6e0a916020e3ac0b91c75d5c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104818 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/source/core/layout/fly.cxx | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index d44af82f1eac..49f522c42d41 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -409,22 +409,26 @@ void SwFlyFrame::FinitDrawObj() if (rCurrentShell.HasDrawView() && rCurrentShell.Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount()) { - if (SwFEShell *const pFEShell = dynamic_cast(&rCurrentShell)) - { // tdf#131679 move any cursor out of fly - SwFlyFrame const*const pOldSelFly = ::GetFlyFromMarked(nullptr, pFEShell); - rCurrentShell.Imp()->GetDrawView()->UnmarkAll(); - if (pOldSelFly) - { - SwPosition const pos(ResolveFlyAnchor(*pOldSelFly->GetFormat())); - SwPaM const temp(pos); - pFEShell->SetSelection(temp); - // could also call SetCursor() like SwFEShell::SelectObj() - // does, but that would access layout a bit much... - } - } - else + SwFlyFrame const*const pOldSelFly = ::GetFlyFromMarked(nullptr, &rCurrentShell); + if (pOldSelFly == this) { - rCurrentShell.Imp()->GetDrawView()->UnmarkAll(); + assert(rCurrentShell.Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1); + if (SwFEShell *const pFEShell = dynamic_cast(&rCurrentShell)) + { // tdf#131679 move any cursor out of fly + rCurrentShell.Imp()->GetDrawView()->UnmarkAll(); + if (pOldSelFly) + { + SwPosition const pos(ResolveFlyAnchor(*pOldSelFly->GetFormat())); + SwPaM const temp(pos); + pFEShell->SetSelection(temp); + // could also call SetCursor() like SwFEShell::SelectObj() + // does, but that would access layout a bit much... + } + } + else + { + rCurrentShell.Imp()->GetDrawView()->UnmarkAll(); + } } } }