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

New commits:
commit 15fb24db540dc29883346d7e8e37d96e4fe8dfb1
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sat Mar 12 20:24:45 2022 +0000
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Sun Mar 13 12:50:00 2022 +0100

    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 <fit...@ubuntu.com>
    Tested-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sw/source/uibase/shells/annotsh.cxx 
b/sw/source/uibase/shells/annotsh.cxx
index b05fedf7c5ae..4647656a0226 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)

Reply via email to