Kaydet (Commit) 32a082a7 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Use SolarMutexGuard directly

Change-Id: Ic133d616d730e332de7354d5de4a5ab21944378f
üst fd7479de
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <stdexcept> #include <stdexcept>
#include <algorithm> #include <algorithm>
#include <threadhelp/threadhelpbase.hxx>
#include <threadhelp/transactionbase.hxx> #include <threadhelp/transactionbase.hxx>
#include <general.h> #include <general.h>
...@@ -54,13 +52,10 @@ typedef TFrameContainer::const_iterator TConstFrameI ...@@ -54,13 +52,10 @@ typedef TFrameContainer::const_iterator TConstFrameI
It's possible to set one of these frames as active or deactive. You could have full index-access to It's possible to set one of these frames as active or deactive. You could have full index-access to
container-items. container-items.
@base ThreadHelpBase
guarantee right initialized lock member during boostrap!
@devstatus ready to use @devstatus ready to use
@threadsafe yes @threadsafe yes
*//*-*************************************************************************************************************/ *//*-*************************************************************************************************************/
class FrameContainer : private ThreadHelpBase class FrameContainer
{ {
// member // member
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <sal/config.h> #include <sal/config.h>
#include <classes/framecontainer.hxx> #include <classes/framecontainer.hxx>
#include <threadhelp/threadhelpbase.hxx>
#include <com/sun/star/frame/XUntitledNumbers.hpp> #include <com/sun/star/frame/XUntitledNumbers.hpp>
#include <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/XController.hpp>
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
*/ */
#include <classes/framecontainer.hxx> #include <classes/framecontainer.hxx>
#include <threadhelp/guard.hxx>
#include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp>
...@@ -33,9 +32,6 @@ namespace framework{ ...@@ -33,9 +32,6 @@ namespace framework{
@threadsafe not necessary - its not a singleton @threadsafe not necessary - its not a singleton
*****************************************************************************************************************/ *****************************************************************************************************************/
FrameContainer::FrameContainer() FrameContainer::FrameContainer()
// initialize base classes first.
// Order is necessary for right initilization of his and OUR member ... m_aLock
: ThreadHelpBase ( &Application::GetSolarMutex() )
/*DEPRECATEME /*DEPRECATEME
, m_bAsyncQuit ( sal_False ) // default must be "disabled"! , m_bAsyncQuit ( sal_False ) // default must be "disabled"!
, m_aAsyncCall ( LINK( this, FrameContainer, implts_asyncQuit ) ) , m_aAsyncCall ( LINK( this, FrameContainer, implts_asyncQuit ) )
...@@ -70,11 +66,8 @@ void FrameContainer::append( const css::uno::Reference< css::frame::XFrame >& xF ...@@ -70,11 +66,8 @@ void FrameContainer::append( const css::uno::Reference< css::frame::XFrame >& xF
{ {
if (xFrame.is() && ! exist(xFrame)) if (xFrame.is() && ! exist(xFrame))
{ {
/* SAFE { */ SolarMutexGuard g;
Guard aWriteLock( m_aLock );
m_aContainer.push_back( xFrame ); m_aContainer.push_back( xFrame );
aWriteLock.unlock();
/* } SAFE */
} }
} }
...@@ -91,9 +84,7 @@ void FrameContainer::append( const css::uno::Reference< css::frame::XFrame >& xF ...@@ -91,9 +84,7 @@ void FrameContainer::append( const css::uno::Reference< css::frame::XFrame >& xF
*****************************************************************************************************************/ *****************************************************************************************************************/
void FrameContainer::remove( const css::uno::Reference< css::frame::XFrame >& xFrame ) void FrameContainer::remove( const css::uno::Reference< css::frame::XFrame >& xFrame )
{ {
/* SAFE { */ SolarMutexGuard g;
// write lock necessary for follwing erase()!
Guard aWriteLock( m_aLock );
TFrameIterator aSearchedItem = ::std::find( m_aContainer.begin(), m_aContainer.end(), xFrame ); TFrameIterator aSearchedItem = ::std::find( m_aContainer.begin(), m_aContainer.end(), xFrame );
if (aSearchedItem!=m_aContainer.end()) if (aSearchedItem!=m_aContainer.end())
...@@ -104,9 +95,6 @@ void FrameContainer::remove( const css::uno::Reference< css::frame::XFrame >& xF ...@@ -104,9 +95,6 @@ void FrameContainer::remove( const css::uno::Reference< css::frame::XFrame >& xF
if (m_xActiveFrame==xFrame) if (m_xActiveFrame==xFrame)
m_xActiveFrame = css::uno::Reference< css::frame::XFrame >(); m_xActiveFrame = css::uno::Reference< css::frame::XFrame >();
} }
aWriteLock.unlock();
// } SAFE
} }
/**-*************************************************************************************************************** /**-***************************************************************************************************************
...@@ -123,10 +111,8 @@ void FrameContainer::remove( const css::uno::Reference< css::frame::XFrame >& xF ...@@ -123,10 +111,8 @@ void FrameContainer::remove( const css::uno::Reference< css::frame::XFrame >& xF
*****************************************************************************************************************/ *****************************************************************************************************************/
sal_Bool FrameContainer::exist( const css::uno::Reference< css::frame::XFrame >& xFrame ) const sal_Bool FrameContainer::exist( const css::uno::Reference< css::frame::XFrame >& xFrame ) const
{ {
/* SAFE { */ SolarMutexGuard g;
Guard aReadLock( m_aLock );
return( ::std::find( m_aContainer.begin(), m_aContainer.end(), xFrame ) != m_aContainer.end() ); return( ::std::find( m_aContainer.begin(), m_aContainer.end(), xFrame ) != m_aContainer.end() );
/* } SAFE */
} }
/**-*************************************************************************************************************** /**-***************************************************************************************************************
...@@ -137,18 +123,13 @@ sal_Bool FrameContainer::exist( const css::uno::Reference< css::frame::XFrame >& ...@@ -137,18 +123,13 @@ sal_Bool FrameContainer::exist( const css::uno::Reference< css::frame::XFrame >&
*****************************************************************************************************************/ *****************************************************************************************************************/
void FrameContainer::clear() void FrameContainer::clear()
{ {
// SAFE { SolarMutexGuard g;
Guard aWriteLock( m_aLock );
// Clear the container ... // Clear the container ...
m_aContainer.clear(); m_aContainer.clear();
// ... and don't forget to reset the active frame. // ... and don't forget to reset the active frame.
// Its an reference to a valid container-item. // Its an reference to a valid container-item.
// But no container item => no active frame! // But no container item => no active frame!
m_xActiveFrame = css::uno::Reference< css::frame::XFrame >(); m_xActiveFrame = css::uno::Reference< css::frame::XFrame >();
aWriteLock.unlock();
// } SAFE
} }
/**-*************************************************************************************************************** /**-***************************************************************************************************************
...@@ -164,10 +145,8 @@ void FrameContainer::clear() ...@@ -164,10 +145,8 @@ void FrameContainer::clear()
*****************************************************************************************************************/ *****************************************************************************************************************/
sal_uInt32 FrameContainer::getCount() const sal_uInt32 FrameContainer::getCount() const
{ {
/* SAFE { */ SolarMutexGuard g;
Guard aReadLock( m_aLock );
return( (sal_uInt32)m_aContainer.size() ); return( (sal_uInt32)m_aContainer.size() );
/* } SAFE */
} }
/**-*************************************************************************************************************** /**-***************************************************************************************************************
...@@ -192,11 +171,8 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::operator[]( sal_uInt32 ...@@ -192,11 +171,8 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::operator[]( sal_uInt32
{ {
// Get element form container WITH automatic test of ranges! // Get element form container WITH automatic test of ranges!
// If index not valid, a out_of_range exception is thrown. // If index not valid, a out_of_range exception is thrown.
/* SAFE { */ SolarMutexGuard g;
Guard aReadLock( m_aLock );
xFrame = m_aContainer.at( nIndex ); xFrame = m_aContainer.at( nIndex );
aReadLock.unlock();
/* } SAFE */
} }
catch( const std::out_of_range& ) catch( const std::out_of_range& )
{ {
...@@ -217,17 +193,11 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::operator[]( sal_uInt32 ...@@ -217,17 +193,11 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::operator[]( sal_uInt32
*****************************************************************************************************************/ *****************************************************************************************************************/
css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > FrameContainer::getAllElements() const css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > FrameContainer::getAllElements() const
{ {
/* SAFE { */ SolarMutexGuard g;
Guard aReadLock( m_aLock );
sal_Int32 nPosition = 0; sal_Int32 nPosition = 0;
css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > lElements ( (sal_uInt32)m_aContainer.size() ); css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > lElements ( (sal_uInt32)m_aContainer.size() );
for (TConstFrameIterator pItem=m_aContainer.begin(); pItem!=m_aContainer.end(); ++pItem) for (TConstFrameIterator pItem=m_aContainer.begin(); pItem!=m_aContainer.end(); ++pItem)
lElements[nPosition++] = *pItem; lElements[nPosition++] = *pItem;
aReadLock.unlock();
/* } SAFE */
return lElements; return lElements;
} }
...@@ -245,11 +215,8 @@ void FrameContainer::setActive( const css::uno::Reference< css::frame::XFrame >& ...@@ -245,11 +215,8 @@ void FrameContainer::setActive( const css::uno::Reference< css::frame::XFrame >&
{ {
if ( !xFrame.is() || exist(xFrame) ) if ( !xFrame.is() || exist(xFrame) )
{ {
/* SAFE { */ SolarMutexGuard g;
Guard aWriteLock( m_aLock );
m_xActiveFrame = xFrame; m_xActiveFrame = xFrame;
aWriteLock.unlock();
/* } SAFE */
} }
} }
...@@ -265,10 +232,8 @@ void FrameContainer::setActive( const css::uno::Reference< css::frame::XFrame >& ...@@ -265,10 +232,8 @@ void FrameContainer::setActive( const css::uno::Reference< css::frame::XFrame >&
*****************************************************************************************************************/ *****************************************************************************************************************/
css::uno::Reference< css::frame::XFrame > FrameContainer::getActive() const css::uno::Reference< css::frame::XFrame > FrameContainer::getActive() const
{ {
/* SAFE { */ SolarMutexGuard g;
Guard aReadLock( m_aLock );
return m_xActiveFrame; return m_xActiveFrame;
/* } SAFE */
} }
/**-*************************************************************************************************************** /**-***************************************************************************************************************
...@@ -284,9 +249,7 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::getActive() const ...@@ -284,9 +249,7 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::getActive() const
*****************************************************************************************************************/ *****************************************************************************************************************/
css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnAllChildrens( const OUString& sName ) const css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnAllChildrens( const OUString& sName ) const
{ {
/* SAFE { */ SolarMutexGuard g;
Guard aReadLock( m_aLock );
// Step over all child frames. But if direct child isn't the right one search on his children first - before // Step over all child frames. But if direct child isn't the right one search on his children first - before
// you go to next direct child of this container! // you go to next direct child of this container!
css::uno::Reference< css::frame::XFrame > xSearchedFrame; css::uno::Reference< css::frame::XFrame > xSearchedFrame;
...@@ -304,8 +267,6 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnAllChildrens( ...@@ -304,8 +267,6 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnAllChildrens(
break; break;
} }
} }
aReadLock.unlock();
/* } SAFE */
return xSearchedFrame; return xSearchedFrame;
} }
...@@ -322,9 +283,7 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnAllChildrens( ...@@ -322,9 +283,7 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnAllChildrens(
*****************************************************************************************************************/ *****************************************************************************************************************/
css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnDirectChildrens( const OUString& sName ) const css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnDirectChildrens( const OUString& sName ) const
{ {
/* SAFE { */ SolarMutexGuard g;
Guard aReadLock( m_aLock );
css::uno::Reference< css::frame::XFrame > xSearchedFrame; css::uno::Reference< css::frame::XFrame > xSearchedFrame;
for( TConstFrameIterator pIterator=m_aContainer.begin(); pIterator!=m_aContainer.end(); ++pIterator ) for( TConstFrameIterator pIterator=m_aContainer.begin(); pIterator!=m_aContainer.end(); ++pIterator )
{ {
...@@ -334,8 +293,6 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnDirectChildren ...@@ -334,8 +293,6 @@ css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnDirectChildren
break; break;
} }
} }
aReadLock.unlock();
/* } SAFE */
return xSearchedFrame; return xSearchedFrame;
} }
......
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