summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2020-11-19 14:00:57 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2021-01-25 14:41:51 +0100
commite26eb908bdb2dee1f6610732ee92ee0b12ea5f35 (patch)
tree4a90a473b1bb60065494d868e41a9e0a870a4ce7 /sfx2
parent4bcd5c31904550af2fc78f9863980494cfccd52d (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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107137
Diffstat (limited to 'sfx2')
-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 516648f145e0..dbde2724589d 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -202,6 +202,8 @@ void SidebarController::disposeDecks()
void SAL_CALL SidebarController::disposing()
{
+ SolarMutexGuard aSolarMutexGuard;
+
mpCloseIndicator.disposeAndClear();
maFocusManager.Clear();
@@ -259,6 +261,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.
@@ -271,7 +275,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();
}
@@ -279,16 +285,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;
@@ -303,12 +317,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 7d0687462122..ea5c0497aa8e 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 e793c4c77e00..08c142e6ff4e 100644
--- a/sfx2/source/sidebar/Theme.cxx
+++ b/sfx2/source/sidebar/Theme.cxx
@@ -345,6 +345,8 @@ void Theme::UpdateTheme()
void SAL_CALL Theme::disposing()
{
+ SolarMutexGuard aGuard;
+
ChangeListeners aListeners;
aListeners.swap(maChangeListeners);
@@ -387,6 +389,8 @@ void SAL_CALL Theme::setPropertyValue (
const ::rtl::OUString& rsPropertyName,
const css::uno::Any& rValue)
{
+ SolarMutexGuard aGuard;
+
PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
if (iId == maPropertyNameToIdMap.end())
throw beans::UnknownPropertyException(rsPropertyName);
@@ -429,6 +433,8 @@ void SAL_CALL Theme::setPropertyValue (
Any SAL_CALL Theme::getPropertyValue (
const ::rtl::OUString& rsPropertyName)
{
+ SolarMutexGuard aGuard;
+
PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
if (iId == maPropertyNameToIdMap.end())
throw beans::UnknownPropertyException();
@@ -446,6 +452,8 @@ void SAL_CALL Theme::addPropertyChangeListener(
const ::rtl::OUString& rsPropertyName,
const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener)
{
+ SolarMutexGuard aGuard;
+
ThemeItem eItem (AnyItem_);
if (rsPropertyName.getLength() > 0)
{
@@ -468,6 +476,8 @@ void SAL_CALL Theme::removePropertyChangeListener(
const ::rtl::OUString& rsPropertyName,
const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener)
{
+ SolarMutexGuard aGuard;
+
ThemeItem eItem (AnyItem_);
if (rsPropertyName.getLength() > 0)
{
@@ -500,6 +510,8 @@ void SAL_CALL Theme::addVetoableChangeListener(
const ::rtl::OUString& rsPropertyName,
const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener)
{
+ SolarMutexGuard aGuard;
+
ThemeItem eItem (AnyItem_);
if (rsPropertyName.getLength() > 0)
{
@@ -522,6 +534,8 @@ void SAL_CALL Theme::removeVetoableChangeListener(
const ::rtl::OUString& rsPropertyName,
const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener)
{
+ SolarMutexGuard aGuard;
+
ThemeItem eItem (AnyItem_);
if (rsPropertyName.getLength() > 0)
{
@@ -551,6 +565,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_);
@@ -576,6 +592,8 @@ css::uno::Sequence<css::beans::Property> SAL_CALL Theme::getProperties()
beans::Property SAL_CALL Theme::getPropertyByName (const ::rtl::OUString& rsPropertyName)
{
+ SolarMutexGuard aGuard;
+
PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
if (iId == maPropertyNameToIdMap.end())
throw beans::UnknownPropertyException();
@@ -595,6 +613,8 @@ beans::Property SAL_CALL Theme::getPropertyByName (const ::rtl::OUString& rsProp
sal_Bool SAL_CALL Theme::hasPropertyByName (const ::rtl::OUString& rsPropertyName)
{
+ SolarMutexGuard aGuard;
+
PropertyNameToIdMap::const_iterator iId (maPropertyNameToIdMap.find(rsPropertyName));
if (iId == maPropertyNameToIdMap.end())
return false;