Kaydet (Commit) 90cee97b authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Use SolarMutexGuard directly

Change-Id: Id9828f95673d1eaf87e6a1c22bf8f07e6861f2f4
üst 503d8938
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#ifndef INCLUDED_FRAMEWORK_INC_HELPER_PERSISTENTWINDOWSTATE_HXX #ifndef INCLUDED_FRAMEWORK_INC_HELPER_PERSISTENTWINDOWSTATE_HXX
#define INCLUDED_FRAMEWORK_INC_HELPER_PERSISTENTWINDOWSTATE_HXX #define INCLUDED_FRAMEWORK_INC_HELPER_PERSISTENTWINDOWSTATE_HXX
#include <threadhelp/threadhelpbase.hxx>
#include <macros/xinterface.hxx> #include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx> #include <macros/xtypeprovider.hxx>
#include <general.h> #include <general.h>
...@@ -47,19 +46,13 @@ namespace framework{ ...@@ -47,19 +46,13 @@ namespace framework{
we store its current position and size to the configuration. Every time a new component is we store its current position and size to the configuration. Every time a new component is
attached to a frame first time(!) we restore this information again. attached to a frame first time(!) we restore this information again.
@base ThreadHelpBase
guarantee right initialized lock member during startup of instances of this class.
@base OWeakObject @base OWeakObject
implements ref counting for this class. implements ref counting for this class.
@devstatus ready @devstatus ready
@threadsafe yes @threadsafe yes
*//*-*************************************************************************************************************/ *//*-*************************************************************************************************************/
class PersistentWindowState : // baseclasses (order necessary for right initialization!) class PersistentWindowState : public ::cppu::WeakImplHelper2<
private ThreadHelpBase,
// interfaces
public ::cppu::WeakImplHelper2<
css::lang::XInitialization, css::lang::XInitialization,
css::frame::XFrameActionListener > // => XEventListener css::frame::XFrameActionListener > // => XEventListener
{ {
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <pattern/window.hxx> #include <pattern/window.hxx>
#include <helper/persistentwindowstate.hxx> #include <helper/persistentwindowstate.hxx>
#include <threadhelp/guard.hxx>
#include <macros/generic.hxx> #include <macros/generic.hxx>
#include <services.h> #include <services.h>
...@@ -45,8 +44,7 @@ namespace framework{ ...@@ -45,8 +44,7 @@ namespace framework{
PersistentWindowState::PersistentWindowState(const css::uno::Reference< css::uno::XComponentContext >& xContext) PersistentWindowState::PersistentWindowState(const css::uno::Reference< css::uno::XComponentContext >& xContext)
: ThreadHelpBase (&Application::GetSolarMutex()) : m_xContext (xContext )
, m_xContext (xContext )
, m_bWindowStateAlreadySet(sal_False ) , m_bWindowStateAlreadySet(sal_False )
{ {
} }
...@@ -76,12 +74,10 @@ void SAL_CALL PersistentWindowState::initialize(const css::uno::Sequence< css::u ...@@ -76,12 +74,10 @@ void SAL_CALL PersistentWindowState::initialize(const css::uno::Sequence< css::u
static_cast< ::cppu::OWeakObject* >(this), static_cast< ::cppu::OWeakObject* >(this),
1); 1);
// SAFE -> ---------------------------------- {
Guard aWriteLock(m_aLock); SolarMutexGuard g;
// hold the frame as weak reference(!) so it can die everytimes :-) m_xFrame = xFrame;
m_xFrame = xFrame; }
aWriteLock.unlock();
// <- SAFE ----------------------------------
// start listening // start listening
xFrame->addFrameActionListener(this); xFrame->addFrameActionListener(this);
...@@ -91,13 +87,15 @@ void SAL_CALL PersistentWindowState::initialize(const css::uno::Sequence< css::u ...@@ -91,13 +87,15 @@ void SAL_CALL PersistentWindowState::initialize(const css::uno::Sequence< css::u
void SAL_CALL PersistentWindowState::frameAction(const css::frame::FrameActionEvent& aEvent) void SAL_CALL PersistentWindowState::frameAction(const css::frame::FrameActionEvent& aEvent)
throw(css::uno::RuntimeException, std::exception) throw(css::uno::RuntimeException, std::exception)
{ {
// SAFE -> ---------------------------------- css::uno::Reference< css::uno::XComponentContext > xContext;
Guard aReadLock(m_aLock); css::uno::Reference< css::frame::XFrame > xFrame;
css::uno::Reference< css::uno::XComponentContext > xContext = m_xContext; sal_Bool bRestoreWindowState;
css::uno::Reference< css::frame::XFrame > xFrame(m_xFrame.get(), css::uno::UNO_QUERY); {
sal_Bool bRestoreWindowState = !m_bWindowStateAlreadySet; SolarMutexGuard g;
aReadLock.unlock(); xContext = m_xContext;
// <- SAFE ---------------------------------- xFrame.set(m_xFrame.get(), css::uno::UNO_QUERY);
bRestoreWindowState = !m_bWindowStateAlreadySet;
}
// frame already gone ? We hold it weak only ... // frame already gone ? We hold it weak only ...
if (!xFrame.is()) if (!xFrame.is())
...@@ -121,11 +119,8 @@ void SAL_CALL PersistentWindowState::frameAction(const css::frame::FrameActionEv ...@@ -121,11 +119,8 @@ void SAL_CALL PersistentWindowState::frameAction(const css::frame::FrameActionEv
{ {
OUString sWindowState = PersistentWindowState::implst_getWindowStateFromConfig(xContext, sModuleName); OUString sWindowState = PersistentWindowState::implst_getWindowStateFromConfig(xContext, sModuleName);
PersistentWindowState::implst_setWindowStateOnWindow(xWindow,sWindowState); PersistentWindowState::implst_setWindowStateOnWindow(xWindow,sWindowState);
// SAFE -> ---------------------------------- SolarMutexGuard g;
Guard aWriteLock(m_aLock);
m_bWindowStateAlreadySet = sal_True; m_bWindowStateAlreadySet = sal_True;
aWriteLock.unlock();
// <- SAFE ----------------------------------
} }
} }
break; break;
......
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