sc/source/ui/drawfunc/futext3.cxx |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 25dd1b089fedec1a7ba45f3a3be7d10217165106
Author:     Maxim Monastirsky <momonas...@gmail.com>
AuthorDate: Thu Mar 9 02:37:19 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Mar 9 10:01:57 2023 +0000

    tdf#154050 Unset external pointer before destroying
    
    Regression of 48ca2336251d62ac2e90300cd9945fb84b1cddd8
    ("tdf#125040 Avoid flickering on context change").
    Before that commit the state of toolbar commands was
    updating async, which is how it managed to not crash.
    
    Change-Id: I07e2ce25faf848c7db33dd029b54a98bafcf8fa9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148518
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonas...@gmail.com>
    (cherry picked from commit 37b2bb1f6c18b915286264682bf0b3c25f0d552a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148501
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sc/source/ui/drawfunc/futext3.cxx 
b/sc/source/ui/drawfunc/futext3.cxx
index 1c13beea9388..a0db57860945 100644
--- a/sc/source/ui/drawfunc/futext3.cxx
+++ b/sc/source/ui/drawfunc/futext3.cxx
@@ -92,6 +92,11 @@ void FuText::StopEditMode()
     if( pNote )
         rDoc.LockStreamValid(true);     // only the affected sheet is 
invalidated below
 
+    /*  Unset the outliner undo manager before the call to SdrEndTextEdit.
+        SdrObjEditView::SdrEndTextEdit destroys it, but then 
ScDrawView::SdrEndTextEdit
+        initiates some UI update which might try to access the now invalid 
pointer. */
+    rViewShell.SetDrawTextUndo( nullptr );
+
     /*  SdrObjEditView::SdrEndTextEdit() may try to delete the entire drawing
         object, if it does not contain text and has invisible border and fill.
         This must not happen for note caption objects. They will be removed
@@ -102,9 +107,6 @@ void FuText::StopEditMode()
         case. */
     /*SdrEndTextEditKind eResult =*/ pView->SdrEndTextEdit( pNote != nullptr );
 
-    // or ScEndTextEdit (with drawview.hxx)
-    rViewShell.SetDrawTextUndo( nullptr );
-
     vcl::Cursor* pCur = pWindow->GetCursor();
     if( pCur && pCur->IsVisible() )
         pCur->Hide();

Reply via email to