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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Fri Mar 24 09:55:21 UTC 2017


 chart2/source/controller/main/ChartController.cxx        |    9 +++++----
 chart2/source/controller/main/ChartController_Tools.cxx  |    3 ++-
 chart2/source/controller/main/ChartController_Window.cxx |   12 +++---------
 3 files changed, 10 insertions(+), 14 deletions(-)

New commits:
commit 9c2884ae4bf6db13334a1d8301721c27f0b889f7
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Thu Mar 23 17:26:35 2017 +0100

    when getting the naked VCL Window from UNO: hold the solar mutex
    
    Change-Id: Ia3513d67e09cdc9748a24aeffce0ec59cab30cc9
    Also: fix some obvious violations of the above.
    Reviewed-on: https://gerrit.libreoffice.org/35605
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>

diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index d67868972049..542b061ff086 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -506,13 +506,13 @@ void SAL_CALL ChartController::attachFrame(
 //XModeChangeListener
 void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent )
 {
+    SolarMutexGuard aGuard;
     auto pChartWindow(GetChartWindow());
     //adjust controller to view status changes
 
     if( rEvent.NewMode == "dirty" )
     {
         //the view has become dirty, we should repaint it if we have a window
-        SolarMutexGuard aGuard;
         if( pChartWindow )
             pChartWindow->ForceInvalidate();
     }
@@ -520,7 +520,6 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent
     {
         //the view is about to become invalid so end all actions on it
         impl_invalidateAccessible();
-        SolarMutexGuard aGuard;
         if( m_pDrawViewWrapper && m_pDrawViewWrapper->IsTextEdit() )
             this->EndTextEdit();
         if( m_pDrawViewWrapper )
@@ -542,7 +541,6 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent
                 if(m_pDrawModelWrapper)
                 {
                     {
-                        SolarMutexGuard aGuard;
                         if( m_pDrawViewWrapper )
                             m_pDrawViewWrapper->ReInit();
                     }
@@ -556,7 +554,6 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent
                     impl_initializeAccessible();
 
                     {
-                        SolarMutexGuard aGuard;
                         if( pChartWindow )
                             pChartWindow->Invalidate();
                     }
@@ -1450,6 +1447,10 @@ DrawViewWrapper* ChartController::GetDrawViewWrapper()
 
 VclPtr<ChartWindow> ChartController::GetChartWindow()
 {
+    // clients getting the naked VCL Window from UNO should always have the
+    // solar mutex (and keep it over the lifetime of this ptr), as VCL might
+    // might deinit otherwise
+    DBG_TESTSOLARMUTEX();
     if(!m_xViewWindow.is())
         return nullptr;
     return dynamic_cast<ChartWindow*>(m_xViewWindow.get());
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 6a33c1c7f319..502c649ab6bd 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -250,7 +250,7 @@ void ChartController::executeDispatch_Paste()
 {
     SolarMutexGuard aGuard;
     auto pChartWindow(GetChartWindow());
-    if( GetChartWindow() )
+    if( pChartWindow )
     {
         Graphic aGraphic;
         // paste location: center of window
@@ -330,6 +330,7 @@ void ChartController::impl_PasteGraphic(
     uno::Reference< graphic::XGraphic > & xGraphic,
     const ::Point & /* aPosition */ )
 {
+    DBG_TESTSOLARMUTEX();
     // note: the XPropertySet of the model is the old API. Also the property
     // "AdditionalShapes" that is used there.
     uno::Reference< beans::XPropertySet > xModelProp( getModel(), uno::UNO_QUERY );
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index feaa6961e48a..b48f2d04716d 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -920,10 +920,10 @@ void ChartController::execute_Resize()
 
 void ChartController::execute_Command( const CommandEvent& rCEvt )
 {
+    SolarMutexGuard aGuard;
     auto pChartWindow(GetChartWindow());
     bool bIsAction = false;
     {
-        SolarMutexGuard aGuard;
         DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
         if(!pChartWindow || !pDrawViewWrapper)
             return;
@@ -934,7 +934,6 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
     if(rCEvt.GetCommand() == CommandEventId::ContextMenu && !bIsAction)
     {
         {
-            SolarMutexGuard aGuard;
             if(pChartWindow)
                 pChartWindow->ReleaseMouse();
         }
@@ -948,7 +947,6 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
         Point aPos( rCEvt.GetMousePosPixel() );
         if( !rCEvt.IsMouseEvent() )
         {
-            SolarMutexGuard aGuard;
             if(pChartWindow)
                 aPos = pChartWindow->GetPointerState().maPos;
         }
@@ -1236,7 +1234,6 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
              ( rCEvt.GetCommand() == CommandEventId::InputContextChange ) )
     {
         //#i84417# enable editing with IME
-        SolarMutexGuard aGuard;
         if( m_pDrawViewWrapper )
             m_pDrawViewWrapper->Command( rCEvt, pChartWindow );
     }
@@ -1244,6 +1241,7 @@ void ChartController::execute_Command( const CommandEvent& rCEvt )
 
 bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
 {
+    SolarMutexGuard aGuard;
     bool bReturn=false;
 
     DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper;
@@ -1271,7 +1269,6 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
         return bReturn;
 
     {
-        SolarMutexGuard aGuard;
         if( pDrawViewWrapper->IsTextEdit() )
         {
             if( pDrawViewWrapper->KeyInput(rKEvt, pChartWindow) )
@@ -1373,7 +1370,6 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
                     if( bAlternate && pChartWindow )
                     {
                         // together with Alt-key: 1 px in each direction
-                        SolarMutexGuard aGuard;
                         if( pChartWindow )
                         {
                             Size aPixelSize = pChartWindow->PixelToLogic( Size( 2, 2 ));
@@ -1404,7 +1400,6 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
                     if( bAlternate && pChartWindow )
                     {
                         // together with Alt-key: 1 px
-                        SolarMutexGuard aGuard;
                         if(pChartWindow)
                         {
                             Size aPixelSize = pChartWindow->PixelToLogic( Size( 1, 1 ));
@@ -1507,8 +1502,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
         bReturn = executeDispatch_Delete();
         if( ! bReturn )
         {
-            SolarMutexGuard aGuard;
-            ScopedVclPtrInstance<InfoBox>(GetChartWindow(), SCH_RESSTR(STR_ACTION_NOTPOSSIBLE))->Execute();
+            ScopedVclPtrInstance<InfoBox>(pChartWindow, SCH_RESSTR(STR_ACTION_NOTPOSSIBLE))->Execute();
         }
     }
 


More information about the Libreoffice-commits mailing list