diff options
Diffstat (limited to 'dbaccess/source')
-rw-r--r-- | dbaccess/source/core/dataaccess/ModelImpl.hxx | 22 | ||||
-rw-r--r-- | dbaccess/source/ui/app/AppController.cxx | 1 |
2 files changed, 21 insertions, 2 deletions
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.hxx b/dbaccess/source/core/dataaccess/ModelImpl.hxx index c57042dc928e..439e7ae3a370 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.hxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.hxx @@ -66,6 +66,7 @@ #include <connectivity/CommonTools.hxx> #include <cppuhelper/propshlp.hxx> #include <cppuhelper/weakref.hxx> +#include <vcl/svapp.hxx> #include <sfx2/docmacromode.hxx> #include <sfx2/docstoragemodifylistener.hxx> #include <unotools/sharedunocomponent.hxx> @@ -569,9 +570,13 @@ private: Just put this guard onto the stack at the beginning of your method. Don't bother yourself with a MutexGuard, checks for being disposed, and the like. */ -class ModelMethodGuard : public ::osl::ResettableMutexGuard +class ModelMethodGuard { private: + // to avoid deadlocks, lock SolarMutex too, and before the own osl::Mutex + SolarMutexResettableGuard m_SolarGuard; + ::osl::ResettableMutexGuard m_OslGuard; + typedef ::osl::ResettableMutexGuard BaseMutexGuard; public: @@ -584,11 +589,24 @@ public: If the given component is already disposed */ explicit ModelMethodGuard( const ModelDependentComponent& _component ) - :BaseMutexGuard( _component.getMutex( ModelDependentComponent::GuardAccess() ) ) + : m_OslGuard(_component.getMutex(ModelDependentComponent::GuardAccess())) { _component.checkDisposed(); } + void clear() + { + m_OslGuard.clear(); + // note: this only releases *once* so may still be locked + m_SolarGuard.clear(); // SolarMutex last + } + + void reset() + { + m_SolarGuard.reset(); // SolarMutex first + m_OslGuard.reset(); + } + ~ModelMethodGuard() { } diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index ed47cffb5fe4..d1206dcbc959 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -2584,6 +2584,7 @@ void OApplicationController::OnFirstControllerConnected() void SAL_CALL OApplicationController::attachFrame( const Reference< XFrame > & i_rxFrame ) throw( RuntimeException, std::exception ) { + SolarMutexGuard aSolarGuard; // avoid deadlock in XModel calls ::osl::MutexGuard aGuard( getMutex() ); OGenericUnoController::attachFrame( i_rxFrame ); |