include/vcl/vclptr.hxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
New commits: commit efc39e11332265a34f8fddc3bdc635cadb7668d8 Author: Noel Grandin <[email protected]> AuthorDate: Mon Feb 23 11:51:21 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Mon Feb 23 17:30:01 2026 +0100 prevent ScopedVclPtr auto-convert to VclPtr Change-Id: Ib32e1a2e648f0f43b1a9f04eaf64c20e81e3e788 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200040 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx index 8333f1a1b1a4..34de43334a82 100644 --- a/include/vcl/vclptr.hxx +++ b/include/vcl/vclptr.hxx @@ -65,6 +65,9 @@ template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( } // namespace vcl::detail +template <class reference_type> +class ScopedVclPtr; + /** * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. * @@ -99,6 +102,12 @@ public: : m_rInnerRef(pBody, SAL_NO_ACQUIRE) {} + /** Prevent auto-conversion of ScopedVclPtr to VclPtr, which defeats the purpose of + ScopedVclPtr. + */ + VclPtr (const ScopedVclPtr<reference_type> &) = delete; + VclPtr (ScopedVclPtr<reference_type> &&) = delete; + /** Up-casting conversion constructor: Copies interface reference. Does not work for up-casts to ambiguous bases. For the special case of @@ -183,6 +192,12 @@ public: return *this; } + /** Prevent auto-conversion of ScopedVclPtr to VclPtr, which defeats the purpose of + ScopedVclPtr. + */ + VclPtr& operator=(const ScopedVclPtr<reference_type> &) = delete; + VclPtr& operator=(ScopedVclPtr<reference_type> &&) = delete; + operator reference_type * () const { return m_rInnerRef.get();
