diff options
author | Michael Stahl <mst@openoffice.org> | 2010-01-08 17:13:47 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2010-01-08 17:13:47 +0100 |
commit | b52a742c0e16ee38c397033100853b8b0feb4857 (patch) | |
tree | b3a3a504b0c15a5973318790170e6d9699f73199 | |
parent | 106e60da5471448468698ef526d1f5b67eb3f234 (diff) |
swunolocking1: #i105557#: unobaseclass.hxx: add UnoImplPtr:
new smart pointer template UnoImplPtr: calls dtor with SolarMutex locked.
-rw-r--r-- | sw/inc/unobaseclass.hxx | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx index 43418f9585..ddd8002d5c 100644 --- a/sw/inc/unobaseclass.hxx +++ b/sw/inc/unobaseclass.hxx @@ -27,8 +27,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _UNOBASECLASS_HXX -#define _UNOBASECLASS_HXX +#ifndef SW_UNOBASECLASS_HXX +#define SW_UNOBASECLASS_HXX #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/container/XEnumeration.hpp> @@ -102,5 +102,42 @@ class UnoActionRemoveContext /// helper function for implementing SwClient::Modify void ClientModify(SwClient* pClient, SfxPoolItem *pOld, SfxPoolItem *pNew); -#endif + +#include <boost/utility.hpp> +#include <osl/diagnose.h> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> + +namespace sw { + + template<typename T> class UnoImplPtr + : private ::boost::noncopyable + { + private: + T * m_p; + + public: + UnoImplPtr(T *const i_p) + : m_p(i_p) + { + OSL_ENSURE(i_p, "UnoImplPtr: null"); + } + + ~UnoImplPtr() + { + ::vos::OGuard g(Application::GetSolarMutex()); + delete m_p; // #i105557#: call dtor with locked solar mutex + m_p = 0; + } + + T & operator * () const { return *m_p; } + + T * operator ->() const { return m_p; } + + T * get () const { return m_p; } + }; + +} // namespace sw + +#endif // SW_UNOBASECLASS_HXX |