diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-03-14 22:16:11 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-10 11:03:10 +0100 |
commit | bc139dde60a25a7ccb60446c7cb8475ab794bfdc (patch) | |
tree | f1107a965bc332f73d23e5fb650cb3e3421e0117 /include/vcl/outdev.hxx | |
parent | add some more helpful paranoia to disposeOnce. (diff) | |
download | core-bc139dde60a25a7ccb60446c7cb8475ab794bfdc.tar.gz core-bc139dde60a25a7ccb60446c7cb8475ab794bfdc.zip |
vclptr: move down impl. to OutputDevice
Ultimately we will want to ref-count & VclPtr OutputDevice instances
separately from Window - but for now merge. This helps fix the amazing
lifecycle foo in toolkit/
Change-Id: If40ee9f645c87aff08815926205e908205bdd67a
Diffstat (limited to 'include/vcl/outdev.hxx')
-rw-r--r-- | include/vcl/outdev.hxx | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 4cf24545c928..e53fc65a982e 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -263,6 +263,26 @@ class VCL_DLLPUBLIC OutputDevice 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. +private: + mutable int mnRefCnt; // reference count + + template<typename T> friend class ::rtl::Reference; + template<typename T> friend class ::VclPtr; + + inline void acquire() const + { + mnRefCnt++; + } + + inline void release() const + { + if (!--mnRefCnt) + delete const_cast<OutputDevice*>(this); + } + private: OutputDevice(const OutputDevice&) SAL_DELETED_FUNCTION; OutputDevice& operator=(const OutputDevice&) SAL_DELETED_FUNCTION; @@ -352,6 +372,7 @@ private: mutable bool mbTextSpecial : 1; mutable bool mbRefPoint : 1; mutable bool mbEnableRTL : 1; + mutable bool mbDisposed : 1; /** @name Initialization and accessor functions */ @@ -359,10 +380,17 @@ 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(); + public: /** Get the graphic context that the output device uses to draw on. |