[Libreoffice-commits] core.git: include/vcl
Noel Grandin
noel at peralex.com
Fri Sep 9 06:38:22 UTC 2016
include/vcl/vclptr.hxx | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
New commits:
commit 976a4803e4cca4c5104c0ed60544a91a50ada012
Author: Noel Grandin <noel at peralex.com>
Date: Wed Sep 7 10:19:45 2016 +0200
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 at gmail.com>
Tested-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index 436a358..b4ef553 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
More information about the Libreoffice-commits
mailing list