[Libreoffice-commits] core.git: include/vcl sw/source

Stephan Bergmann sbergman at redhat.com
Tue May 30 16:21:46 UTC 2017


 include/vcl/vclptr.hxx           |   16 ++++++++++++++++
 sw/source/uibase/inc/fldwrap.hxx |    4 ++--
 2 files changed, 18 insertions(+), 2 deletions(-)

New commits:
commit ac5ff992409944f6d2f828290b574261a691a0ed
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue May 30 18:19:34 2017 +0200

    Dispose pDlgInterface member during destruction
    
    Requires a VclPtr -> ScopedVclPtr assignment operator, similar to the existing
    VclPtr -> ScopedVclPtr constructor.
    
    Change-Id: I2b43967ee84f90eea20f8eaa17741229473752b1

diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx
index f809176a77d4..a11552635082 100644
--- a/include/vcl/vclptr.hxx
+++ b/include/vcl/vclptr.hxx
@@ -347,6 +347,22 @@ public:
     {
     }
 
+    /** Up-casting assignment operator.
+
+        Does not work for up-casts to ambiguous bases.
+
+        @param rRef another VclPtr
+    */
+    template<typename derived_type>
+    typename std::enable_if<
+        std::is_base_of<reference_type, derived_type>::value,
+        ScopedVclPtr &>::type
+    operator =(VclPtr<derived_type> const & rRef)
+    {
+        disposeAndReset(rRef.get());
+        return *this;
+    }
+
     /**
      * Override and disallow this, to prevent people accidentally calling it and actually
      * getting VclPtr::Create and getting a naked VclPtr<> instance
diff --git a/sw/source/uibase/inc/fldwrap.hxx b/sw/source/uibase/inc/fldwrap.hxx
index 0ebd58b45a45..0d8b58e7142c 100644
--- a/sw/source/uibase/inc/fldwrap.hxx
+++ b/sw/source/uibase/inc/fldwrap.hxx
@@ -25,7 +25,7 @@ class AbstractSwFieldDlg;
 class SwFieldDlgWrapper : public SwChildWinWrapper
 {
 public:
-    VclPtr<AbstractSwFieldDlg> pDlgInterface;
+    ScopedVclPtr<AbstractSwFieldDlg> pDlgInterface;
     SwFieldDlgWrapper( vcl::Window* pParent, sal_uInt16 nId,
                         SfxBindings* pBindings, SfxChildWinInfo* pInfo );
 
@@ -39,7 +39,7 @@ public:
 class SwFieldDataOnlyDlgWrapper : public SwChildWinWrapper
 {
 public:
-    VclPtr<AbstractSwFieldDlg> pDlgInterface;
+    ScopedVclPtr<AbstractSwFieldDlg> pDlgInterface;
     SwFieldDataOnlyDlgWrapper( vcl::Window* pParent, sal_uInt16 nId,
                         SfxBindings* pBindings, SfxChildWinInfo* pInfo );
 


More information about the Libreoffice-commits mailing list