sw/source/uibase/shells/annotsh.cxx |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit e54ac357ee669cfc7cb5c68eca4ddce27824ae9a
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sat Mar 12 20:24:45 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Mar 13 11:24:35 2022 +0100

    tdf#147929 "undo" may delete the current SwAnnotationShell
    
    Change-Id: I69fb7e65e28743aa73e943e02d5029654b5543cb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131450
    Tested-by: Julien Nabet <serval2...@yahoo.fr>
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/uibase/shells/annotsh.cxx 
b/sw/source/uibase/shells/annotsh.cxx
index ce410ba0e3a9..481d550a0328 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)

Reply via email to