cui/source/tabpages/tpbitmap.cxx |    2 +-
 include/vcl/vclptr.hxx           |   15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit bf93ab62f053f9b3c650acb01d47958c6c1044dc
Author:     Noel Grandin <[email protected]>
AuthorDate: Mon Feb 23 11:51:21 2026 +0200
Commit:     Mike Kaganski <[email protected]>
CommitDate: Thu Mar 5 15:40:11 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]>
    (cherry picked from commit efc39e11332265a34f8fddc3bdc635cadb7668d8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200998
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx
index 250ed05f9eff..85334db87349 100644
--- a/cui/source/tabpages/tpbitmap.cxx
+++ b/cui/source/tabpages/tpbitmap.cxx
@@ -973,7 +973,7 @@ tools::Long SvxBitmapTabPage::AddBitmap(const 
GraphicObject& rGraphicObject, con
     m_pBitmapList->Insert(std::move(xBitmapEntry), nLastPos);
 
     Bitmap aBitmap = m_pBitmapList->GetBitmapForPreview(nLastPos, aIconSize);
-    VclPtr<VirtualDevice> pVDev = GetVirtualDevice(aBitmap);
+    ScopedVclPtr<VirtualDevice> pVDev = GetVirtualDevice(aBitmap);
     Bitmap aBmp = pVDev->GetBitmap(Point(), pVDev->GetOutputSizePixel());
 
     OUString sId = nLastPos > 0 ? m_xBitmapLB->get_id(nLastPos - 1) : 
OUString();
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();

Reply via email to