[Libreoffice-commits] core.git: Branch 'feature/vclref' - accessibility/source compilerplugins/clang include/vcl vcl/source vcl/unx vcl/workben

Noel Grandin noel at peralex.com
Tue Mar 17 00:45:01 PDT 2015


 accessibility/source/standard/vclxaccessiblebox.cxx |   12 +++++-----
 compilerplugins/clang/vclwidgets.cxx                |   22 ++++++--------------
 include/vcl/layout.hxx                              |    1 
 include/vcl/window.hxx                              |    2 -
 vcl/source/app/dbggui.cxx                           |    4 ++-
 vcl/source/window/layout.cxx                        |    5 ++++
 vcl/unx/generic/app/i18n_status.cxx                 |    1 
 vcl/workben/svpclient.cxx                           |    1 
 8 files changed, 25 insertions(+), 23 deletions(-)

New commits:
commit ad81db2f9d8419cba0f5e388ce8c365667fb8f9c
Author: Noel Grandin <noel at peralex.com>
Date:   Tue Mar 17 08:55:36 2015 +0200

    vclwidget: make sure we have an explicit destructor
    
    Change-Id: I50490ad8957e8069e72e855f0f5a3b694218fd6b

diff --git a/accessibility/source/standard/vclxaccessiblebox.cxx b/accessibility/source/standard/vclxaccessiblebox.cxx
index aa4995c..d83e13a 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)
@@ -336,7 +336,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());
@@ -407,7 +407,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;
@@ -416,7 +416,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;
@@ -541,7 +541,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)
@@ -555,7 +555,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 7686297..9de6af8 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 40a4593..776b8ce 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 5f0be55..143f953 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -486,7 +486,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 bcbaee6e..1cc0698 100644
--- a/vcl/source/app/dbggui.cxx
+++ b/vcl/source/app/dbggui.cxx
@@ -218,6 +218,7 @@ public:
     void            SetInfoText( const OUString& rStr );
 private:
     virtual void    dispose() SAL_OVERRIDE;
+    virtual         ~DbgInfoDialog() { disposeOnce(); }
 };
 
 class DbgDialog : public ModalDialog
@@ -239,6 +240,7 @@ public:
     void            RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
 private:
     virtual void    dispose() SAL_OVERRIDE;
+    virtual         ~DbgDialog() { disposeOnce(); }
 };
 
 DbgDialog::DbgDialog() :
@@ -832,7 +834,7 @@ void DbgGUIStart()
 
     if ( pData )
     {
-        boost::scoped_ptr<DbgDialog> pDialog(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 08e61eb..d176356 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1889,6 +1889,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 b92759b..bd5157a 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 0bb5875..ce6edb1 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 );


More information about the Libreoffice-commits mailing list