From ac5ff992409944f6d2f828290b574261a691a0ed Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 30 May 2017 18:19:34 +0200 Subject: Dispose pDlgInterface member during destruction Requires a VclPtr -> ScopedVclPtr assignment operator, similar to the existing VclPtr -> ScopedVclPtr constructor. Change-Id: I2b43967ee84f90eea20f8eaa17741229473752b1 --- include/vcl/vclptr.hxx | 16 ++++++++++++++++ sw/source/uibase/inc/fldwrap.hxx | 4 ++-- 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 std::enable_if< + std::is_base_of::value, + ScopedVclPtr &>::type + operator =(VclPtr 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 pDlgInterface; + ScopedVclPtr pDlgInterface; SwFieldDlgWrapper( vcl::Window* pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ); @@ -39,7 +39,7 @@ public: class SwFieldDataOnlyDlgWrapper : public SwChildWinWrapper { public: - VclPtr pDlgInterface; + ScopedVclPtr pDlgInterface; SwFieldDataOnlyDlgWrapper( vcl::Window* pParent, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ); -- cgit