Kaydet (Commit) 65b718da authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Use SolarMutexGuard directly

Change-Id: I8e76a9cc9c06420fde3a1c5564410624ce5a91ec
üst 6013967b
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <xml/acceleratorconfigurationwriter.hxx> #include <xml/acceleratorconfigurationwriter.hxx>
#include <xml/saxnamespacefilter.hxx> #include <xml/saxnamespacefilter.hxx>
#include <threadhelp/guard.hxx>
#include <acceleratorconst.h> #include <acceleratorconst.h>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
...@@ -36,6 +35,7 @@ ...@@ -36,6 +35,7 @@
#include <comphelper/sequenceashashmap.hxx> #include <comphelper/sequenceashashmap.hxx>
#include <i18nlangtag/languagetag.hxx> #include <i18nlangtag/languagetag.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include <vcl/svapp.hxx>
using namespace framework; using namespace framework;
...@@ -115,23 +115,22 @@ DocumentAcceleratorConfiguration::DocumentAcceleratorConfiguration( ...@@ -115,23 +115,22 @@ DocumentAcceleratorConfiguration::DocumentAcceleratorConfiguration(
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& lArguments) const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& lArguments)
: DocumentAcceleratorConfiguration_BASE(xContext) : DocumentAcceleratorConfiguration_BASE(xContext)
{ {
Guard aWriteLock(m_aLock);
css::uno::Reference<css::embed::XStorage> xRoot;
if (lArguments.getLength() == 1 && (lArguments[0] >>= xRoot))
{
m_xDocumentRoot = xRoot;
}
else
{ {
::comphelper::SequenceAsHashMap lArgs(lArguments); SolarMutexGuard g;
m_xDocumentRoot = lArgs.getUnpackedValueOrDefault( css::uno::Reference<css::embed::XStorage> xRoot;
OUString("DocumentRoot"), if (lArguments.getLength() == 1 && (lArguments[0] >>= xRoot))
css::uno::Reference< css::embed::XStorage >()); {
m_xDocumentRoot = xRoot;
}
else
{
::comphelper::SequenceAsHashMap lArgs(lArguments);
m_xDocumentRoot = lArgs.getUnpackedValueOrDefault(
OUString("DocumentRoot"),
css::uno::Reference< css::embed::XStorage >());
}
} }
aWriteLock.unlock();
impl_ts_fillCache(); impl_ts_fillCache();
} }
...@@ -147,12 +146,12 @@ void SAL_CALL DocumentAcceleratorConfiguration::setStorage(const css::uno::Refer ...@@ -147,12 +146,12 @@ void SAL_CALL DocumentAcceleratorConfiguration::setStorage(const css::uno::Refer
{ {
// Attention! xStorage must be accepted too, if it's NULL ! // Attention! xStorage must be accepted too, if it's NULL !
// SAFE -> ---------------------------------- sal_Bool bForgetOldStorages;
Guard aWriteLock(m_aLock); {
sal_Bool bForgetOldStorages = m_xDocumentRoot.is(); SolarMutexGuard g;
m_xDocumentRoot = xStorage; bForgetOldStorages = m_xDocumentRoot.is();
aWriteLock.unlock(); m_xDocumentRoot = xStorage;
// <- SAFE ---------------------------------- }
if (bForgetOldStorages) if (bForgetOldStorages)
impl_ts_clearCache(); impl_ts_clearCache();
...@@ -165,20 +164,18 @@ void SAL_CALL DocumentAcceleratorConfiguration::setStorage(const css::uno::Refer ...@@ -165,20 +164,18 @@ void SAL_CALL DocumentAcceleratorConfiguration::setStorage(const css::uno::Refer
sal_Bool SAL_CALL DocumentAcceleratorConfiguration::hasStorage() sal_Bool SAL_CALL DocumentAcceleratorConfiguration::hasStorage()
throw(css::uno::RuntimeException, std::exception) throw(css::uno::RuntimeException, std::exception)
{ {
// SAFE -> ---------------------------------- SolarMutexGuard g;
Guard aReadLock(m_aLock);
return m_xDocumentRoot.is(); return m_xDocumentRoot.is();
// <- SAFE ----------------------------------
} }
void DocumentAcceleratorConfiguration::impl_ts_fillCache() void DocumentAcceleratorConfiguration::impl_ts_fillCache()
{ {
// SAFE -> ---------------------------------- css::uno::Reference< css::embed::XStorage > xDocumentRoot;
Guard aReadLock(m_aLock); {
css::uno::Reference< css::embed::XStorage > xDocumentRoot = m_xDocumentRoot; SolarMutexGuard g;
aReadLock.unlock(); xDocumentRoot = m_xDocumentRoot;
// <- SAFE ---------------------------------- }
// Sometimes we must live without a document root. // Sometimes we must live without a document root.
// E.g. if the document is readonly ... // E.g. if the document is readonly ...
......
...@@ -69,8 +69,7 @@ typedef PresetHandler AcceleratorPresets; ...@@ -69,8 +69,7 @@ typedef PresetHandler AcceleratorPresets;
/** /**
implements a read/write access to the accelerator configuration. implements a read/write access to the accelerator configuration.
*/ */
class XMLBasedAcceleratorConfiguration : protected ThreadHelpBase, // attention! Must be the first base class to guarentee right initialize lock ... class XMLBasedAcceleratorConfiguration : public IStorageListener,
public IStorageListener,
public ::cppu::WeakImplHelper2< public ::cppu::WeakImplHelper2<
css::form::XReset, // TODO use XPresetHandler instead if available css::form::XReset, // TODO use XPresetHandler instead if available
css::ui::XAcceleratorConfiguration > // => css::ui::XUIConfigurationPersistence css::ui::XAcceleratorConfiguration > // => css::ui::XUIConfigurationPersistence
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment