[Libreoffice-commits] core.git: 2 commits - sc/source

Caolán McNamara caolanm at redhat.com
Mon Nov 4 14:12:00 CET 2013


 sc/source/ui/app/inputhdl.cxx    |   19 +++++++++++++------
 sc/source/ui/formdlg/formula.cxx |   17 +++++++++++++++++
 2 files changed, 30 insertions(+), 6 deletions(-)

New commits:
commit a9d85d62a889288b17899c8defc020da487d8b36
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Nov 4 13:07:00 2013 +0000

    fdo#69971 formula dialog crash when Paint restores EditEngine listener
    
    We need the EditEngine Modification handler of the inputbar that we are feeding
    to be disabled while this dialog is open. Otherwise we end up in a situation
    where...
    a) this ScFormulaDlg changes the editengine
    b) the modify callback gets called
    c) which also modifies the editengine
    d) on return from that modify handler the editengine attempts to use
       old node pointers which were replaced and removed by c
    
    We turn it off in the ctor and back on in the dtor, but if calc has to repaint,
    e.g. when switching to another window and back, then in ScMultiTextWnd::Paint a
    new editengine will have been created via GetEditView with its default
    Modification handler enabled. So ensure its off everytime we will access it via
    InputReplaceSelection pScMod->InputEnterHandler();
    
    I wonder if we should really be calling ScMultiTextWnd::GetEditView
    (which creates an EditView if one does not already exist) in
    ScMultiTextWnd::Paint or just check for pEditView directly, but that
    then leading to the need for it to be explicitly created somewhere else.
    As it stands in ScMultiTextWnd::Paint(...) the "if ( pView )" can never
    be false.
    
    Change-Id: I2f6df9ce0cc7ec59e8be33f4e67d91422796d251

diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index ad0bbab..70571d2 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -608,6 +608,23 @@ formula::FormEditData* ScFormulaDlg::getFormEditData() const
 void ScFormulaDlg::setCurrentFormula(const OUString& _sReplacement)
 {
     ScModule* pScMod = SC_MOD();
+    {
+        //fdo#69971 We need the EditEngine Modification handler of the inputbar that we
+        //are feeding to be disabled while this dialog is open. Otherwise we end up in
+        //a situation where...
+        //a) this ScFormulaDlg changes the editengine
+        //b) the modify callback gets called
+        //c) which also modifies the editengine
+        //d) on return from that modify handler the editengine attempts to use
+        //   old node pointers which were replaced and removed by c
+        //
+        //We turn it off in the ctor and back on in the dtor, but if calc has
+        //to repaint, e.g. when switching to another window and back, then in
+        //ScMultiTextWnd::Paint a new editengine will have been created via
+        //GetEditView with its default Modification handler enabled. So ensure
+        //its off when we will access it via InputReplaceSelection
+        pScMod->InputEnterHandler();
+    }
     pScMod->InputReplaceSelection(_sReplacement);
 }
 void ScFormulaDlg::setSelection(xub_StrLen _nStart,xub_StrLen _nEnd)
commit a012483e95e1788844092b1973c9e025af7b1da1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Nov 4 11:39:28 2013 +0000

    small optimization, don't get selection unless it gets used
    
    Change-Id: Ibc359a8dbb26ef066dc43535eaf9835c4c7e9314

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 7aef609..f838c49 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2115,20 +2115,27 @@ static void lcl_SetTopSelection( EditView* pEditView, ESelection& rSel )
 
 void ScInputHandler::SyncViews( EditView* pSourceView )
 {
-    ESelection aSel;
-
     if (pSourceView)
     {
-        aSel = pSourceView->GetSelection();
+        bool bSelectionForTopView = false;
         if (pTopView && pTopView != pSourceView)
-            pTopView->SetSelection( aSel );
+            bSelectionForTopView = true;
+        bool bSelectionForTableView = false;
         if (pTableView && pTableView != pSourceView)
-            lcl_SetTopSelection( pTableView, aSel );
+            bSelectionForTableView = true;
+        if (bSelectionForTopView || bSelectionForTableView)
+        {
+            ESelection aSel(pSourceView->GetSelection());
+            if (bSelectionForTopView)
+                pTopView->SetSelection(aSel);
+            if (bSelectionForTableView)
+                lcl_SetTopSelection(pTableView, aSel);
+        }
     }
     // Only sync selection from topView if we are actually editiing there
     else if (pTopView && pTableView)
     {
-        aSel = pTopView->GetSelection();
+        ESelection aSel(pTopView->GetSelection());
         lcl_SetTopSelection( pTableView, aSel );
     }
 }


More information about the Libreoffice-commits mailing list