tdf#147929 "undo" may delete the current SwAnnotationShell
Change-Id: I69fb7e65e28743aa73e943e02d5029654b5543cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131450
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx
index ce410ba..481d550 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -1518,8 +1518,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();
@@ -1592,10 +1596,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)