tdf#147928 "undo" may delete the current SwAnnotationShell
Change-Id: I69fb7e65e28743aa73e943e02d5029654b5543cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131366
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Tested-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
(cherry picked from commit 15fb24db540dc29883346d7e8e37d96e4fe8dfb1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131472
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx
index b05fedf..4647656 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -1505,8 +1505,12 @@ void SwAnnotationShell::ExecUndo(SfxRequest &rReq)
SwWrtShell &rSh = m_rView.GetWrtShell();
SwUndoId nUndoId(SwUndoId::EMPTY);
tools::Long aOldHeight = m_rView.GetPostItMgr()->HasActiveSidebarWin()
? m_rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight()
// tdf#147929 get these before "undo" which may delete this SwAnnotationShell
SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
SfxBindings& rBindings = m_rView.GetViewFrame()->GetBindings();
tools::Long aOldHeight = pPostItMgr->HasActiveSidebarWin()
? pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight()
: 0;
sal_uInt16 nId = rReq.GetSlot();
@@ -1579,10 +1583,10 @@ void SwAnnotationShell::ExecUndo(SfxRequest &rReq)
}
}
m_rView.GetViewFrame()->GetBindings().InvalidateAll(false);
rBindings.InvalidateAll(false);
if (m_rView.GetPostItMgr()->HasActiveSidebarWin())
m_rView.GetPostItMgr()->GetActiveSidebarWin()->ResizeIfNecessary(aOldHeight,m_rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight());
if (pPostItMgr->HasActiveSidebarWin())
pPostItMgr->GetActiveSidebarWin()->ResizeIfNecessary(aOldHeight, pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight());
}
void SwAnnotationShell::StateUndo(SfxItemSet &rSet)