Kaydet (Commit) 3f1d1539 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Use an osl::Mutex directly

Change-Id: I3df1bcd733637db8d967809e9abb0d2775d58efb
üst 9baa3cf7
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_LOADDISPATCHER_HXX #define INCLUDED_FRAMEWORK_SOURCE_INC_DISPATCH_LOADDISPATCHER_HXX
#include <loadenv/loadenv.hxx> #include <loadenv/loadenv.hxx>
#include <threadhelp/threadhelpbase.hxx>
#include <com/sun/star/frame/XNotifyingDispatch.hpp> #include <com/sun/star/frame/XNotifyingDispatch.hpp>
#include <com/sun/star/frame/XSynchronousDispatch.hpp> #include <com/sun/star/frame/XSynchronousDispatch.hpp>
......
...@@ -21,9 +21,6 @@ ...@@ -21,9 +21,6 @@
#define INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_ACTIONLOCKGUARD_HXX #define INCLUDED_FRAMEWORK_SOURCE_INC_LOADENV_ACTIONLOCKGUARD_HXX
#include <threadhelp/threadhelpbase.hxx>
#include <threadhelp/guard.hxx>
#include <com/sun/star/document/XActionLockable.hpp> #include <com/sun/star/document/XActionLockable.hpp>
...@@ -35,12 +32,13 @@ namespace framework{ ...@@ -35,12 +32,13 @@ namespace framework{
@descr This guard should be used to be shure, that any lock will be @descr This guard should be used to be shure, that any lock will be
released. Otherwise the locaked document can hinder the office on shutdown! released. Otherwise the locaked document can hinder the office on shutdown!
*/ */
class ActionLockGuard : private ThreadHelpBase class ActionLockGuard
{ {
// member // member
private: private:
osl::Mutex m_mutex;
/** @short points to the object, which can be locked from outside. */ /** @short points to the object, which can be locked from outside. */
css::uno::Reference< css::document::XActionLockable > m_xActionLock; css::uno::Reference< css::document::XActionLockable > m_xActionLock;
...@@ -62,8 +60,7 @@ class ActionLockGuard : private ThreadHelpBase ...@@ -62,8 +60,7 @@ class ActionLockGuard : private ThreadHelpBase
in a mode "use guard for more then one resources". in a mode "use guard for more then one resources".
*/ */
ActionLockGuard() ActionLockGuard()
: ThreadHelpBase ( ) : m_bActionLocked(sal_False)
, m_bActionLocked(sal_False)
{ {
} }
...@@ -74,8 +71,7 @@ class ActionLockGuard : private ThreadHelpBase ...@@ -74,8 +71,7 @@ class ActionLockGuard : private ThreadHelpBase
points to the outside resource, which should be locked. points to the outside resource, which should be locked.
*/ */
ActionLockGuard(const css::uno::Reference< css::document::XActionLockable >& xLock) ActionLockGuard(const css::uno::Reference< css::document::XActionLockable >& xLock)
: ThreadHelpBase ( ) : m_bActionLocked(sal_False)
, m_bActionLocked(sal_False)
{ {
setResource(xLock); setResource(xLock);
} }
...@@ -103,8 +99,7 @@ class ActionLockGuard : private ThreadHelpBase ...@@ -103,8 +99,7 @@ class ActionLockGuard : private ThreadHelpBase
*/ */
virtual sal_Bool setResource(const css::uno::Reference< css::document::XActionLockable >& xLock) virtual sal_Bool setResource(const css::uno::Reference< css::document::XActionLockable >& xLock)
{ {
// SAFE -> .......................... osl::MutexGuard g(m_mutex);
Guard aMutexLock(m_aLock);
if (m_bActionLocked || !xLock.is()) if (m_bActionLocked || !xLock.is())
return sal_False; return sal_False;
...@@ -112,7 +107,6 @@ class ActionLockGuard : private ThreadHelpBase ...@@ -112,7 +107,6 @@ class ActionLockGuard : private ThreadHelpBase
m_xActionLock = xLock; m_xActionLock = xLock;
m_xActionLock->addActionLock(); m_xActionLock->addActionLock();
m_bActionLocked = m_xActionLock->isActionLocked(); m_bActionLocked = m_xActionLock->isActionLocked();
// <- SAFE ..........................
return sal_True; return sal_True;
} }
...@@ -132,7 +126,7 @@ class ActionLockGuard : private ThreadHelpBase ...@@ -132,7 +126,7 @@ class ActionLockGuard : private ThreadHelpBase
virtual void freeResource() virtual void freeResource()
{ {
// SAFE -> .......................... // SAFE -> ..........................
Guard aMutexLock(m_aLock); osl::ClearableMutexGuard aMutexLock(m_mutex);
css::uno::Reference< css::document::XActionLockable > xLock = m_xActionLock ; css::uno::Reference< css::document::XActionLockable > xLock = m_xActionLock ;
sal_Bool bLocked = m_bActionLocked; sal_Bool bLocked = m_bActionLocked;
...@@ -140,7 +134,7 @@ class ActionLockGuard : private ThreadHelpBase ...@@ -140,7 +134,7 @@ class ActionLockGuard : private ThreadHelpBase
m_xActionLock.clear(); m_xActionLock.clear();
m_bActionLocked = sal_False; m_bActionLocked = sal_False;
aMutexLock.unlock(); aMutexLock.clear();
// <- SAFE .......................... // <- SAFE ..........................
if (bLocked && xLock.is()) if (bLocked && xLock.is())
...@@ -151,24 +145,19 @@ class ActionLockGuard : private ThreadHelpBase ...@@ -151,24 +145,19 @@ class ActionLockGuard : private ThreadHelpBase
/** @short lock the internal wrapped resource, if its not already done. */ /** @short lock the internal wrapped resource, if its not already done. */
virtual void lock() virtual void lock()
{ {
// SAFE -> .......................... osl::MutexGuard g(m_mutex);
Guard aMutexLock(m_aLock);
if (!m_bActionLocked && m_xActionLock.is()) if (!m_bActionLocked && m_xActionLock.is())
{ {
m_xActionLock->addActionLock(); m_xActionLock->addActionLock();
m_bActionLocked = m_xActionLock->isActionLocked(); m_bActionLocked = m_xActionLock->isActionLocked();
} }
// <- SAFE ..........................
} }
/** @short unlock the internal wrapped resource, if its not already done. */ /** @short unlock the internal wrapped resource, if its not already done. */
virtual void unlock() virtual void unlock()
{ {
// SAFE -> .......................... osl::MutexGuard g(m_mutex);
Guard aMutexLock(m_aLock);
if (m_bActionLocked && m_xActionLock.is()) if (m_bActionLocked && m_xActionLock.is())
{ {
m_xActionLock->removeActionLock(); m_xActionLock->removeActionLock();
...@@ -176,7 +165,6 @@ class ActionLockGuard : private ThreadHelpBase ...@@ -176,7 +165,6 @@ class ActionLockGuard : private ThreadHelpBase
// May another guard use the same lock object :-( // May another guard use the same lock object :-(
m_bActionLocked = sal_False; m_bActionLocked = sal_False;
} }
// <- SAFE ..........................
} }
}; };
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <dispatch/dispatchinformationprovider.hxx> #include <dispatch/dispatchinformationprovider.hxx>
#include <classes/framecontainer.hxx> #include <classes/framecontainer.hxx>
#include <classes/propertysethelper.hxx> #include <classes/propertysethelper.hxx>
#include <threadhelp/guard.hxx>
#include <threadhelp/transactionguard.hxx> #include <threadhelp/transactionguard.hxx>
#include <threadhelp/transactionbase.hxx> #include <threadhelp/transactionbase.hxx>
#include <general.h> #include <general.h>
......
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