diff options
author | Noel Grandin <noel@peralex.com> | 2016-09-07 10:19:45 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-09-09 06:37:40 +0000 |
commit | 976a4803e4cca4c5104c0ed60544a91a50ada012 (patch) | |
tree | 5e3369f691273f4129bf035d44b97e5b96d5c69f /include | |
parent | 0f9a81c8f58c1a9e771d7ff90abe3c20e8283f94 (diff) |
disallow calls to ::Create in VclPtr subclasses
where it can be actively dangerous, if the calling code thinks it's
creating a ScopedVclPtrInstance, and it actually only gets a VclPtr
Change-Id: I638b28207d60e8fc4ca3d31000c0735d06ce2eb3
Reviewed-on: https://gerrit.libreoffice.org/28714
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/vcl/vclptr.hxx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx index 436a35859960..b4ef55325cfe 100644 --- a/include/vcl/vclptr.hxx +++ b/include/vcl/vclptr.hxx @@ -281,6 +281,12 @@ public: : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) { } + + /** + * Override and disallow this, to prevent people accidentally calling it and actually + * getting VclPtr::Create and getting a naked VclPtr<> instance + */ + template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; }; template <class reference_type> @@ -339,6 +345,12 @@ public: { } + /** + * Override and disallow this, to prevent people accidentally calling it and actually + * getting VclPtr::Create and getting a naked VclPtr<> instance + */ + template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; + ~ScopedVclPtr() { VclPtr<reference_type>::disposeAndClear(); @@ -382,6 +394,12 @@ public: { } + /** + * Override and disallow this, to prevent people accidentally calling it and actually + * getting VclPtr::Create and getting a naked VclPtr<> instance + */ + template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; + private: // Prevent the above perfect forwarding ctor from hijacking (accidental) // attempts at ScopedVclPtrInstance copy construction (where the hijacking |