diff options
author | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-11-19 14:00:57 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-11-20 02:27:22 +0100 |
commit | cdae2f16ef9da75c1b3f9cc3f8abc3a180f324d1 (patch) | |
tree | 3c7bc03cd63a826521af5806deb6b48ab6068a39 /sfx2 | |
parent | 20ef6c22268b04eef11834292f42d6d831ab31a2 (diff) |
fix tdf#138335 guard sidebar uno methods with SolarMutex
Wasn't threadsafe before; using vcl/gui code, so we need the
SolarMutex.
Change-Id: I3d4407f095837d03ad492fcdf9a08746cf911d25
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106169
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/sidebar/SidebarController.cxx | 23 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarPanelBase.cxx | 14 | ||||
-rw-r--r-- | sfx2/source/sidebar/Theme.cxx | 20 |
3 files changed, 54 insertions, 3 deletions
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 4a0ff69f93ce..f257b5e815ca 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -252,6 +252,8 @@ void SidebarController::disposeDecks() void SAL_CALL SidebarController::disposing() { + SolarMutexGuard aSolarMutexGuard; + mpCloseIndicator.disposeAndClear(); maFocusManager.Clear(); @@ -307,6 +309,8 @@ void SAL_CALL SidebarController::disposing() void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) { + SolarMutexGuard aSolarMutexGuard; + // Update to the requested new context asynchronously to avoid // subtle errors caused by SFX2 which in rare cases can not // properly handle a synchronous update. @@ -318,7 +322,9 @@ void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::Contex if (maRequestedContext != maCurrentContext) { mxCurrentController.set(rEvent.Source, css::uno::UNO_QUERY); - maContextChangeUpdate.RequestCall(); + maContextChangeUpdate.RequestCall(); // async call, not a prob + // calling with held + // solarmutex // TODO: this call is redundant but mandatory for unit test to update context on document loading UpdateConfigurations(); } @@ -326,16 +332,24 @@ void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::Contex void SAL_CALL SidebarController::disposing (const css::lang::EventObject& ) { + SolarMutexGuard aSolarMutexGuard; + dispose(); } void SAL_CALL SidebarController::propertyChange (const css::beans::PropertyChangeEvent& ) { - maPropertyChangeForwarder.RequestCall(); + SolarMutexGuard aSolarMutexGuard; + + maPropertyChangeForwarder.RequestCall(); // async call, not a prob + // to call with held + // solarmutex } void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEvent& rEvent) { + SolarMutexGuard aSolarMutexGuard; + bool bIsReadWrite (true); if (rEvent.IsEnabled) rEvent.State >>= bIsReadWrite; @@ -349,12 +363,15 @@ void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEv SwitchToDefaultDeck(); mnRequestedForceFlags |= SwitchFlag_ForceSwitch; - maContextChangeUpdate.RequestCall(); + maContextChangeUpdate.RequestCall(); // async call, ok to call + // with held solarmutex } } void SAL_CALL SidebarController::requestLayout() { + SolarMutexGuard aSolarMutexGuard; + sal_Int32 nMinimalWidth = 0; if (mpCurrentDeck && !mpCurrentDeck->isDisposed()) { diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx index a1f0b8b6208c..6865047df252 100644 --- a/sfx2/source/sidebar/SidebarPanelBase.cxx +++ b/sfx2/source/sidebar/SidebarPanelBase.cxx @@ -78,6 +78,8 @@ SidebarPanelBase::~SidebarPanelBase() void SAL_CALL SidebarPanelBase::disposing() { + SolarMutexGuard aGuard; + mpControl.disposeAndClear(); if (mxFrame.is()) @@ -94,6 +96,8 @@ void SAL_CALL SidebarPanelBase::disposing() void SAL_CALL SidebarPanelBase::notifyContextChangeEvent ( const ui::ContextChangeEventObject& rEvent) { + SolarMutexGuard aGuard; + IContextChangeReceiver* pContextChangeReceiver = dynamic_cast<IContextChangeReceiver*>(mpControl.get()); if (pContextChangeReceiver != nullptr) @@ -108,6 +112,8 @@ void SAL_CALL SidebarPanelBase::notifyContextChangeEvent ( void SAL_CALL SidebarPanelBase::disposing ( const css::lang::EventObject&) { + SolarMutexGuard aGuard; + mxFrame = nullptr; mpControl = nullptr; } @@ -141,6 +147,8 @@ Reference<accessibility::XAccessible> SAL_CALL SidebarPanelBase::createAccessibl Reference<awt::XWindow> SAL_CALL SidebarPanelBase::getWindow() { + SolarMutexGuard aGuard; + if (mpControl != nullptr) return Reference<awt::XWindow>( mpControl->GetComponentInterface(), @@ -151,6 +159,8 @@ Reference<awt::XWindow> SAL_CALL SidebarPanelBase::getWindow() ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWidth) { + SolarMutexGuard aGuard; + if (maLayoutSize.Minimum >= 0) return maLayoutSize; else @@ -176,6 +186,8 @@ ui::LayoutSize SAL_CALL SidebarPanelBase::getHeightForWidth (const sal_Int32 nWi sal_Int32 SAL_CALL SidebarPanelBase::getMinimalWidth () { + SolarMutexGuard aGuard; + if (isLayoutEnabled(mpControl)) { // widget layout-based sidebar @@ -187,6 +199,8 @@ sal_Int32 SAL_CALL SidebarPanelBase::getMinimalWidth () void SAL_CALL SidebarPanelBase::updateModel(const css::uno::Reference<css::frame::XModel>& xModel) { + SolarMutexGuard aGuard; + SidebarModelUpdate* pModelUpdate = dynamic_cast<SidebarModelUpdate*>(mpControl.get()); if (!pModelUpdate) return; diff --git a/sfx2/source/sidebar/Theme.cxx b/sfx2/source/sidebar/Theme.cxx index 361a77414a8e..66294a5cd9a3 100644 --- a/sfx2/source/sidebar/Theme.cxx +++ b/sfx2/source/sidebar/Theme.cxx @@ -256,6 +256,8 @@ void Theme::UpdateTheme() void SAL_CALL Theme::disposing() { + SolarMutexGuard aGuard; + ChangeListeners aListeners; aListeners.swap(maChangeListeners); @@ -290,6 +292,8 @@ void SAL_CALL Theme::setPropertyValue ( const OUString& rsPropertyName, const css::uno::Any& rValue) { + SolarMutexGuard aGuard; + PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName)); if (iId == maPropertyNameToIdMap.end()) throw beans::UnknownPropertyException(rsPropertyName); @@ -332,6 +336,8 @@ void SAL_CALL Theme::setPropertyValue ( Any SAL_CALL Theme::getPropertyValue ( const OUString& rsPropertyName) { + SolarMutexGuard aGuard; + PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName)); if (iId == maPropertyNameToIdMap.end()) throw beans::UnknownPropertyException(rsPropertyName); @@ -349,6 +355,8 @@ void SAL_CALL Theme::addPropertyChangeListener( const OUString& rsPropertyName, const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) { + SolarMutexGuard aGuard; + ThemeItem eItem (AnyItem_); if (rsPropertyName.getLength() > 0) { @@ -371,6 +379,8 @@ void SAL_CALL Theme::removePropertyChangeListener( const OUString& rsPropertyName, const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) { + SolarMutexGuard aGuard; + ThemeItem eItem (AnyItem_); if (rsPropertyName.getLength() > 0) { @@ -403,6 +413,8 @@ void SAL_CALL Theme::addVetoableChangeListener( const OUString& rsPropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) { + SolarMutexGuard aGuard; + ThemeItem eItem (AnyItem_); if (rsPropertyName.getLength() > 0) { @@ -425,6 +437,8 @@ void SAL_CALL Theme::removeVetoableChangeListener( const OUString& rsPropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) { + SolarMutexGuard aGuard; + ThemeItem eItem (AnyItem_); if (rsPropertyName.getLength() > 0) { @@ -454,6 +468,8 @@ void SAL_CALL Theme::removeVetoableChangeListener( css::uno::Sequence<css::beans::Property> SAL_CALL Theme::getProperties() { + SolarMutexGuard aGuard; + ::std::vector<beans::Property> aProperties; sal_Int32 const nEnd(End_); @@ -479,6 +495,8 @@ css::uno::Sequence<css::beans::Property> SAL_CALL Theme::getProperties() beans::Property SAL_CALL Theme::getPropertyByName (const OUString& rsPropertyName) { + SolarMutexGuard aGuard; + PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName)); if (iId == maPropertyNameToIdMap.end()) throw beans::UnknownPropertyException(rsPropertyName); @@ -498,6 +516,8 @@ beans::Property SAL_CALL Theme::getPropertyByName (const OUString& rsPropertyNam sal_Bool SAL_CALL Theme::hasPropertyByName (const OUString& rsPropertyName) { + SolarMutexGuard aGuard; + PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName)); if (iId == maPropertyNameToIdMap.end()) return false; |