[Libreoffice-commits] core.git: sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 17 10:33:02 UTC 2020


 sw/source/uibase/ribbar/inputwin.cxx |   23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 806b82d89f3bdf7ac0f9c25df15d40f8817f3353
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Sep 16 16:53:03 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Thu Sep 17 12:32:27 2020 +0200

    sw: fix crash in SwInputWindow::ApplyFormula()
    
    pView is null because the constructor is called from:
    
    10 0x00007fcf1e4d5796 in SfxDispatcher::Update_Impl(bool) (this=0x70a8f40, bForce=false) at sfx2/source/control/dispatch.cxx:1112
    11 0x00007fcf1e975c97 in SfxBaseController::ConnectSfxFrame_Impl(SfxBaseController::ConnectSfxFrame) (this=0x72684f0, i_eConnect=SfxBaseController::E_CONNECT) at sfx2/source/view/sfxbasecontroller.cxx:1249
    
    but the active is set later, from:
    
    0  SfxApplication::SetViewFrame_Impl(SfxViewFrame*) (this=0x38f32d0, pFrame=0x7255b30) at sfx2/source/appl/app.cxx:265
    1  0x00007fcf1e99025c in SfxViewFrame::SetViewFrame(SfxViewFrame*) (pFrame=0x7255b30) at sfx2/source/view/viewfrm.cxx:3326
    2  0x00007fcf1e989181 in SfxViewFrame::MakeActive_Impl(bool) (this=0x7255b30, bGrabFocus=true) at sfx2/source/view/viewfrm.cxx:1931
    3  0x00007fcf1e975d2d in SfxBaseController::ConnectSfxFrame_Impl(SfxBaseController::ConnectSfxFrame) (this=0x72684f0, i_eConnect=SfxBaseController::E_CONNECT) at sfx2/source/view/sfxbasecontroller.cxx:1253
    
    This can only be reproduced if the SwInputWindow is visible in the
    configuration, but it is closed automatically on document close, so not
    sure how i got into this situation; Ctrl+C while it's visible can
    reproduce this anyway.
    
    Change-Id: Iae2c7b6044bfea5cb627804d3b88dde2a83732bf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102875
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/source/uibase/ribbar/inputwin.cxx b/sw/source/uibase/ribbar/inputwin.cxx
index de00c7fc7108..b84681e353f9 100644
--- a/sw/source/uibase/ribbar/inputwin.cxx
+++ b/sw/source/uibase/ribbar/inputwin.cxx
@@ -333,6 +333,18 @@ void SwInputWindow::Click( )
 
 void  SwInputWindow::ApplyFormula()
 {
+    // in case it was created while loading the document, the active view
+    // wasn't initialised at that time, so ShowWin() didn't initialise anything
+    // either - nothing to do
+    if (!pView)
+    {
+        // presumably there must be an active view now since the event arrived
+        SwView *const pActiveView = ::GetActiveView();
+        // this just makes the input window go away, so that the next time it works
+        pActiveView->GetViewFrame()->GetDispatcher()->Execute(FN_EDIT_FORMULA, SfxCallMode::ASYNCHRON);
+        return;
+    }
+
     pView->GetViewFrame()->GetDispatcher()->Lock(false);
     pView->GetEditWin().LockKeyInput(false);
     CleanupUglyHackWithUndo();
@@ -354,8 +366,17 @@ void  SwInputWindow::ApplyFormula()
 
 void  SwInputWindow::CancelFormula()
 {
-    if(!pView)
+    // in case it was created while loading the document, the active view
+    // wasn't initialised at that time, so ShowWin() didn't initialise anything
+    // either - nothing to do
+    if (!pView)
+    {
+        // presumably there must be an active view now since the event arrived
+        SwView *const pActiveView = ::GetActiveView();
+        // this just makes the input window go away, so that the next time it works
+        pActiveView->GetViewFrame()->GetDispatcher()->Execute(FN_EDIT_FORMULA, SfxCallMode::ASYNCHRON);
         return;
+    }
 
     pView->GetViewFrame()->GetDispatcher()->Lock( false );
     pView->GetEditWin().LockKeyInput(false);


More information about the Libreoffice-commits mailing list