summaryrefslogtreecommitdiff
path: root/sw/inc/unobaseclass.hxx
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-01-08 17:13:47 +0100
committerMichael Stahl <mst@openoffice.org>2010-01-08 17:13:47 +0100
commit5e8eac444983d7fcf8e4c102171179dbb6fffed9 (patch)
treea14ff1994ca08362f15dd10ff6cee65e9030fa35 /sw/inc/unobaseclass.hxx
parent4f555e6d5467a2a198113789c5527969e287da9c (diff)
swunolocking1: #i105557#: unobaseclass.hxx: add UnoImplPtr:
new smart pointer template UnoImplPtr: calls dtor with SolarMutex locked.
Diffstat (limited to 'sw/inc/unobaseclass.hxx')
-rw-r--r--sw/inc/unobaseclass.hxx43
1 files changed, 40 insertions, 3 deletions
diff --git a/sw/inc/unobaseclass.hxx b/sw/inc/unobaseclass.hxx
index 75443b2c7584..5f55115f479e 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