diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-06-30 10:47:32 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-07-01 12:51:29 +0100 |
commit | 916943d22a2490a6df976504ff3964d8c65ddfbd (patch) | |
tree | 92d497f524832c6ef98e91427bd547bb88c7d834 | |
parent | 93b615d220d3f12e314920dc8b18c8ae8fc23c94 (diff) |
split out ref-count-base into a base class
Change-Id: I90f86ae62fd03f71f87d2983189b21b0799da6e8
-rw-r--r-- | include/vcl/outdev.hxx | 54 | ||||
-rw-r--r-- | vcl/source/outdev/outdev.cxx | 7 |
2 files changed, 33 insertions, 28 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: diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index 0b6d0aa7ec01..2a8d7476c6eb 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -82,7 +82,6 @@ namespace { // Begin initializer and accessor public functions OutputDevice::OutputDevice() : - mnRefCnt(1), // cf. VclPtrInstance and README.lifecycle maRegion(true), maFillColor( COL_WHITE ), maTextLineColor( COL_TRANSPARENT ), @@ -179,16 +178,14 @@ OutputDevice::OutputDevice() : // #i75163# mpOutDevData->mpViewTransform = NULL; mpOutDevData->mpInverseViewTransform = NULL; - - mbDisposed = false; } -OutputDevice::~OutputDevice() +VclPtrRefCountBase::~VclPtrRefCountBase() { disposeOnce(); } -void OutputDevice::disposeOnce() +void VclPtrRefCountBase::disposeOnce() { if ( mbDisposed ) return; |