summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-05-30 18:19:34 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-05-30 18:19:34 +0200
commitac5ff992409944f6d2f828290b574261a691a0ed (patch)
tree0a87284883145b1b9aa3885fb080e84e812f8e23
parentc1a7994d64648c222de2785ca5f30c549ba3443c (diff)
Dispose pDlgInterface member during destruction
Requires a VclPtr -> ScopedVclPtr assignment operator, similar to the existing VclPtr -> ScopedVclPtr constructor. Change-Id: I2b43967ee84f90eea20f8eaa17741229473752b1
-rw-r--r--include/vcl/vclptr.hxx16
-rw-r--r--sw/source/uibase/inc/fldwrap.hxx4
2 files changed, 18 insertions, 2 deletions
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 );