summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2020-11-19 14:00:57 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-11-20 08:22:50 +0100
commitb379d483e70d2edf868c2fde4b54da2581625d22 (patch)
treec9704e51560bf88d81fb6355762a065a6fdb0c85
parent4102a92b319afc5140c9b2adc4483a6643334b3a (diff)
fix tdf#138335 guard sidebar uno methods with SolarMutex
Wasn't threadsafe before; using vcl/gui code, so we need the SolarMutex. Conflicts: sfx2/source/sidebar/SidebarController.cxx Change-Id: I3d4407f095837d03ad492fcdf9a08746cf911d25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106169 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106211 Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx23
-rw-r--r--sfx2/source/sidebar/SidebarPanelBase.cxx14
-rw-r--r--sfx2/source/sidebar/Theme.cxx20
3 files changed, 54 insertions, 3 deletions
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 5c69f97d0b59..6161967f7920 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -256,6 +256,8 @@ void SidebarController::disposeDecks()
void SAL_CALL SidebarController::disposing()
{
+ SolarMutexGuard aSolarMutexGuard;
+
mpCloseIndicator.disposeAndClear();
maFocusManager.Clear();
@@ -313,6 +315,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.
@@ -325,7 +329,9 @@ void SAL_CALL SidebarController::notifyContextChangeEvent (const css::ui::Contex
{
mxCurrentController.set(rEvent.Source, css::uno::UNO_QUERY);
maAsynchronousDeckSwitch.CancelRequest();
- 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();
}
@@ -333,16 +339,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;
@@ -357,12 +371,15 @@ void SAL_CALL SidebarController::statusChanged (const css::frame::FeatureStateEv
mnRequestedForceFlags |= SwitchFlag_ForceSwitch;
maAsynchronousDeckSwitch.CancelRequest();
- 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 0906dc962d57..4a7ec6ade4fd 100644
--- a/sfx2/source/sidebar/SidebarPanelBase.cxx
+++ b/sfx2/source/sidebar/SidebarPanelBase.cxx
@@ -79,6 +79,8 @@ SidebarPanelBase::~SidebarPanelBase()
void SAL_CALL SidebarPanelBase::disposing()
{
+ SolarMutexGuard aGuard;
+
mpControl.disposeAndClear();
if (mxFrame.is())
@@ -95,6 +97,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)
@@ -109,6 +113,8 @@ void SAL_CALL SidebarPanelBase::notifyContextChangeEvent (
void SAL_CALL SidebarPanelBase::disposing (
const css::lang::EventObject&)
{
+ SolarMutexGuard aGuard;
+
mxFrame = nullptr;
mpControl = nullptr;
}
@@ -142,6 +148,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(),
@@ -152,6 +160,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
@@ -178,6 +188,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
@@ -189,6 +201,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 90ab20e46f15..c3175d9e9f45 100644
--- a/sfx2/source/sidebar/Theme.cxx
+++ b/sfx2/source/sidebar/Theme.cxx
@@ -347,6 +347,8 @@ void Theme::UpdateTheme()
void SAL_CALL Theme::disposing()
{
+ SolarMutexGuard aGuard;
+
ChangeListeners aListeners;
aListeners.swap(maChangeListeners);
@@ -381,6 +383,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);
@@ -423,6 +427,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);
@@ -440,6 +446,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)
{
@@ -462,6 +470,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)
{
@@ -494,6 +504,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)
{
@@ -516,6 +528,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)
{
@@ -545,6 +559,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_);
@@ -570,6 +586,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);
@@ -589,6 +607,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;