diff options
author | Noel Grandin <noel@peralex.com> | 2015-03-17 08:55:36 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-04-10 11:33:58 +0100 |
commit | e35bc27fdc648ee433c755312fa79263b49f1339 (patch) | |
tree | bb84b18a4958f85f3da393c68201fe0ead5eb0fd | |
parent | 683cb12163803af2888b17ee4902e319c8bc49b4 (diff) |
vclwidget: make sure we have an explicit destructor
Change-Id: I50490ad8957e8069e72e855f0f5a3b694218fd6b
-rw-r--r-- | accessibility/source/standard/vclxaccessiblebox.cxx | 12 | ||||
-rw-r--r-- | compilerplugins/clang/vclwidgets.cxx | 22 | ||||
-rw-r--r-- | include/vcl/layout.hxx | 1 | ||||
-rw-r--r-- | include/vcl/window.hxx | 2 | ||||
-rw-r--r-- | vcl/source/app/dbggui.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 5 | ||||
-rw-r--r-- | vcl/unx/generic/app/i18n_status.cxx | 1 | ||||
-rw-r--r-- | vcl/workben/svpclient.cxx | 1 |
8 files changed, 25 insertions, 23 deletions
diff --git a/accessibility/source/standard/vclxaccessiblebox.cxx b/accessibility/source/standard/vclxaccessiblebox.cxx index c5b862623a20..6db5a54fc3f2 100644 --- a/accessibility/source/standard/vclxaccessiblebox.cxx +++ b/accessibility/source/standard/vclxaccessiblebox.cxx @@ -76,7 +76,7 @@ void VCLXAccessibleBox::ProcessWindowChildEvent( const VclWindowEvent& rVclWindo if (m_aBoxType==COMBOBOX) { VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); - if ( ( pComboBox != NULL ) && ( pChildWindow != NULL ) ) + if ( ( pComboBox != nullptr ) && ( pChildWindow != NULL ) ) if (pChildWindow == pComboBox->GetSubEdit()) { if (rVclWindowEvent.GetId() == VCLEVENT_WINDOW_SHOW) @@ -328,7 +328,7 @@ Reference<XAccessible> SAL_CALL VCLXAccessibleBox::getAccessibleChild (sal_Int32 if (m_aBoxType==COMBOBOX) { VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); - if (pComboBox!=NULL && pComboBox->GetSubEdit()!=NULL) + if (pComboBox!=nullptr && pComboBox->GetSubEdit()!=NULL) //Set the edit's acc name the same as parent { pComboBox->GetSubEdit()->SetAccessibleName(getAccessibleName()); @@ -399,7 +399,7 @@ sal_Bool SAL_CALL VCLXAccessibleBox::doAccessibleAction (sal_Int32 nIndex) if (m_aBoxType == COMBOBOX) { VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); - if (pComboBox != NULL) + if (pComboBox != nullptr) { pComboBox->ToggleDropDown(); bNotify = true; @@ -408,7 +408,7 @@ sal_Bool SAL_CALL VCLXAccessibleBox::doAccessibleAction (sal_Int32 nIndex) else if (m_aBoxType == LISTBOX) { VclPtr< ListBox > pListBox = GetAs< ListBox >(); - if (pListBox != NULL) + if (pListBox != nullptr) { pListBox->ToggleDropDown(); bNotify = true; @@ -533,7 +533,7 @@ void VCLXAccessibleBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& r OUString sText; sal_Int32 nEntryCount = 0; VclPtr< ComboBox > pComboBox = GetAs< ComboBox >(); - if (pComboBox != NULL) + if (pComboBox != nullptr) { Edit* pSubEdit = pComboBox->GetSubEdit(); if ( pSubEdit) @@ -547,7 +547,7 @@ void VCLXAccessibleBox::FillAccessibleStateSet( utl::AccessibleStateSetHelper& r { sal_Int32 nSelectedEntryCount = 0; VclPtr< ListBox > pListBox = GetAs< ListBox >(); - if (pListBox != NULL && pListBox->GetEntryCount() > 0) + if (pListBox != nullptr && pListBox->GetEntryCount() > 0) { nSelectedEntryCount = pListBox->GetSelectEntryCount(); if ( nSelectedEntryCount == 0) diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx index 41fb2d2f5756..365451417ece 100644 --- a/compilerplugins/clang/vclwidgets.cxx +++ b/compilerplugins/clang/vclwidgets.cxx @@ -270,6 +270,13 @@ bool VCLWidgets::VisitFieldDecl(const FieldDecl * fieldDecl) { fieldDecl->getLocation()) << fieldDecl->getSourceRange(); } + if (!pParentRecordDecl->hasUserDeclaredDestructor()) { + report( + DiagnosticsEngine::Warning, + "vcl::Window subclass with a VclPtr field MUST have an explicit destructor.", + fieldDecl->getLocation()) + << fieldDecl->getSourceRange(); + } } return true; @@ -294,13 +301,6 @@ bool VCLWidgets::VisitParmVarDecl(ParmVarDecl const * pvDecl) { return true; } - if (!pvDecl->getType()->isReferenceType() && pvDecl->getType().getAsString().find("VclPtr") != std::string::npos) { - report( - DiagnosticsEngine::Warning, - "vcl::Window subclass passed as a VclPtr parameter, should be passed as a raw pointer.", - pvDecl->getCanonicalDecl()->getLocation()) - << pvDecl->getCanonicalDecl()->getSourceRange(); - } return true; } @@ -363,14 +363,6 @@ bool VCLWidgets::VisitFunctionDecl( const FunctionDecl* functionDecl ) && pMethodDecl->getParent()->getQualifiedNameAsString() == "vcl::Window") { return true; } - QualType t1 { compat::getReturnType(*functionDecl) }; - if (t1.getAsString().find("VclPtr") == 0) { - report( - DiagnosticsEngine::Warning, - "VclPtr declared as a return type from a method/function, should be passed as a raw pointer.", - functionDecl->getLocation()) - << functionDecl->getSourceRange(); - } if (functionDecl->hasBody() && pMethodDecl && isDerivedFromWindow(pMethodDecl->getParent())) { // check the last thing that the dispose() method does, is to call into the superclass dispose method if (pMethodDecl->getNameAsString() == "dispose") { diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx index 6e6b04f8eac5..2575142e1d4e 100644 --- a/include/vcl/layout.hxx +++ b/include/vcl/layout.hxx @@ -626,6 +626,7 @@ private: VclPtr<EventBoxHelper> m_aEventBoxHelper; protected: virtual void dispose() SAL_OVERRIDE; + virtual ~VclEventBox(); public: VclEventBox(vcl::Window* pParent) : VclBin(pParent) diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 663d7dddf5d0..5dcfb3543ee1 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -501,7 +501,7 @@ public: protected: /** This is intended to be used to clear any locally held references to other Window-subclass objects */ - virtual void dispose(); + virtual void dispose() SAL_OVERRIDE; SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData ); diff --git a/vcl/source/app/dbggui.cxx b/vcl/source/app/dbggui.cxx index 65e2d1351c82..852220922cda 100644 --- a/vcl/source/app/dbggui.cxx +++ b/vcl/source/app/dbggui.cxx @@ -217,6 +217,7 @@ public: void SetInfoText( const OUString& rStr ); private: virtual void dispose() SAL_OVERRIDE; + virtual ~DbgInfoDialog() { disposeOnce(); } }; class DbgDialog : public ModalDialog @@ -238,6 +239,7 @@ public: void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE; private: virtual void dispose() SAL_OVERRIDE; + virtual ~DbgDialog() { disposeOnce(); } }; DbgDialog::DbgDialog() : @@ -831,7 +833,7 @@ void DbgGUIStart() if ( pData ) { - std::unique_ptr<DbgDialog> xDialog(new DbgDialog); + VclPtr<DbgDialog> pDialog(new DbgDialog); // we switch off dialog tests for the debug dialog sal_uLong nOldFlags = pData->nTestFlags; pData->nTestFlags &= ~DBG_TEST_DIALOG; diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index d0933b12aaf3..34de14a1aeb3 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1903,6 +1903,11 @@ void VclEventBox::Command(const CommandEvent&) //discard events by default to block them reaching children } +VclEventBox::~VclEventBox() +{ + disposeOnce(); +} + void VclEventBox::dispose() { m_aEventBoxHelper.disposeAndClear(); diff --git a/vcl/unx/generic/app/i18n_status.cxx b/vcl/unx/generic/app/i18n_status.cxx index e05f29ca788a..210171363843 100644 --- a/vcl/unx/generic/app/i18n_status.cxx +++ b/vcl/unx/generic/app/i18n_status.cxx @@ -316,6 +316,7 @@ public: virtual void setText( const OUString & ) SAL_OVERRIDE; virtual void show( bool bShow, I18NStatus::ShowReason eReason ) SAL_OVERRIDE; virtual void toggle( bool bOn ) SAL_OVERRIDE; + virtual ~IIIMPStatusWindow() { disposeOnce(); } virtual void dispose() SAL_OVERRIDE; void layout(); diff --git a/vcl/workben/svpclient.cxx b/vcl/workben/svpclient.cxx index 7bbcdf2144f0..ee218bb80687 100644 --- a/vcl/workben/svpclient.cxx +++ b/vcl/workben/svpclient.cxx @@ -108,6 +108,7 @@ public: virtual void Resize() SAL_OVERRIDE; virtual bool Close() SAL_OVERRIDE; + virtual ~MyWin() { disposeOnce(); } virtual void dispose() SAL_OVERRIDE; void parseList( const OString& rList ); |