summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-06-30 10:47:32 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-07-01 12:51:29 +0100
commit916943d22a2490a6df976504ff3964d8c65ddfbd (patch)
tree92d497f524832c6ef98e91427bd547bb88c7d834 /include
parent93b615d220d3f12e314920dc8b18c8ae8fc23c94 (diff)
split out ref-count-base into a base class
Change-Id: I90f86ae62fd03f71f87d2983189b21b0799da6e8
Diffstat (limited to 'include')
-rw-r--r--include/vcl/outdev.hxx54
1 files changed, 31 insertions, 23 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 279cb1eeaa47..9af2f62a63cf 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -312,38 +312,54 @@ namespace vcl {
typedef OutputDevice RenderContext;
}
-class VCL_DLLPUBLIC OutputDevice
+class VCL_DLLPUBLIC VclPtrRefCountBase
{
- friend class PaintHelper;
- friend class Printer;
- friend class VirtualDevice;
- friend class vcl::Window;
- friend class WorkWindow;
- friend class vcl::PDFWriterImpl;
- friend void ImplHandleResize( vcl::Window* pWindow, long nNewWidth, long nNewHeight );
-
- // All of this will need to be replicated in Window
- // or a shared base-class as/when we can break the
- // OutputDevice -> Window inheritance.
+public:
+ VclPtrRefCountBase()
+ : mnRefCnt(1) // cf. VclPtrInstance and README.lifecycle
+ , mbDisposed(false)
+ {
+ }
private:
mutable int mnRefCnt; // reference count
+ mutable bool mbDisposed;
template<typename T> friend class ::rtl::Reference;
template<typename T> friend class ::VclPtr;
- inline void acquire() const
+ void acquire() const
{
assert(mnRefCnt>0);
mnRefCnt++;
}
- inline void release() const
+ void release() const
{
assert(mnRefCnt>0);
if (!--mnRefCnt)
delete this;
}
+protected:
+ virtual void dispose() = 0;
+
+public:
+ /// call the dispose() method if we have not already been disposed.
+ void disposeOnce();
+ bool isDisposed() const { return mbDisposed; }
+ virtual ~VclPtrRefCountBase();
+};
+
+class VCL_DLLPUBLIC OutputDevice : public VclPtrRefCountBase
+{
+ friend class PaintHelper;
+ friend class Printer;
+ friend class VirtualDevice;
+ friend class vcl::Window;
+ friend class WorkWindow;
+ friend class vcl::PDFWriterImpl;
+ friend void ImplHandleResize( vcl::Window* pWindow, long nNewWidth, long nNewHeight );
+
private:
OutputDevice(const OutputDevice&) SAL_DELETED_FUNCTION;
OutputDevice& operator=(const OutputDevice&) SAL_DELETED_FUNCTION;
@@ -433,7 +449,6 @@ private:
mutable bool mbTextSpecial : 1;
mutable bool mbRefPoint : 1;
mutable bool mbEnableRTL : 1;
- mutable bool mbDisposed : 1;
/** @name Initialization and accessor functions
*/
@@ -441,17 +456,10 @@ private:
protected:
OutputDevice();
-public:
- virtual ~OutputDevice();
protected:
/// release all references to other objects.
- virtual void dispose();
-
-public:
- /// call the dispose() method if we have not already been disposed.
- void disposeOnce();
- bool isDisposed() const { return mbDisposed; }
+ virtual void dispose() SAL_OVERRIDE;
public: