diff options
-rw-r--r-- | compilerplugins/clang/vclwidgets.cxx | 53 | ||||
-rw-r--r-- | include/vcl/dialog.hxx | 4 | ||||
-rw-r--r-- | include/vcl/edit.hxx | 2 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 8 |
5 files changed, 30 insertions, 41 deletions
diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx index 896cd3f38889..1f8e05b9692f 100644 --- a/compilerplugins/clang/vclwidgets.cxx +++ b/compilerplugins/clang/vclwidgets.cxx @@ -37,8 +37,6 @@ public: bool VisitParmVarDecl(ParmVarDecl const * decl); - bool VisitVarDecl( const VarDecl* var ); - bool VisitFunctionDecl( const FunctionDecl* var ); }; @@ -90,7 +88,7 @@ bool VCLWidgets::VisitCXXRecordDecl(const CXXRecordDecl * recordDecl) { } bool foundVclPtr = false; for(auto fieldDecl : recordDecl->fields()) { - if (fieldDecl->getType().getAsString().find("VclPtr")==0) { + if (fieldDecl->getType().getAsString().find("VclPtr") != std::string::npos) { foundVclPtr = true; break; } @@ -153,38 +151,24 @@ bool VCLWidgets::VisitFieldDecl(const FieldDecl * fieldDecl) { return true; } -bool VCLWidgets::VisitParmVarDecl(ParmVarDecl const * pvDecl) { +bool VCLWidgets::VisitParmVarDecl(ParmVarDecl const * pvDecl) +{ if (ignoreLocation(pvDecl)) { return true; } - // check if this parameter is derived from Window - if (isPointerToWindowSubclass(pvDecl->getType())) { - report( - DiagnosticsEngine::Remark, - "vcl::Window subclass passed as a pointer parameter, should be wrapped in VclPtr.", - pvDecl->getLocation()) - << pvDecl->getSourceRange(); - } - return true; -} - -bool VCLWidgets::VisitVarDecl( const VarDecl* varDecl ) -{ - if (ignoreLocation(varDecl)) { + // ignore the stuff in the VclPtr template class + const CXXMethodDecl *pMethodDecl = dyn_cast<CXXMethodDecl>(pvDecl->getDeclContext()); + if (pMethodDecl + && pMethodDecl->getParent()->getQualifiedNameAsString().find("VclPtr") != std::string::npos) { return true; } - if (!varDecl->isLocalVarDecl()) - return true; - - // check if this variables type is derived from Window - if (isPointerToWindowSubclass(varDecl->getType())) { + if (pvDecl->getType().getAsString().find("VclPtr") != std::string::npos) { report( - DiagnosticsEngine::Remark, - "vcl::Window subclass declared as a pointer var, should be wrapped in VclPtr.", - varDecl->getLocation()) - << varDecl->getSourceRange(); + DiagnosticsEngine::Warning, + "vcl::Window subclass passed as a VclPtr parameter, should be passed as a raw pointer.", + pvDecl->getLocation()) + << pvDecl->getSourceRange(); } - return true; } @@ -193,12 +177,17 @@ bool VCLWidgets::VisitFunctionDecl( const FunctionDecl* functionDecl ) if (ignoreLocation(functionDecl)) { return true; } + // ignore the stuff in the VclPtr template class + const CXXMethodDecl *pMethodDecl = dyn_cast<CXXMethodDecl>(functionDecl); + if (pMethodDecl + && pMethodDecl->getParent()->getQualifiedNameAsString().find("VclPtr") != std::string::npos) { + return true; + } QualType t1 { compat::getReturnType(*functionDecl) }; - // check if this variables type is derived from Window - if (isPointerToWindowSubclass(t1)) { + if (t1.getAsString().find("VclPtr") != std::string::npos) { report( - DiagnosticsEngine::Remark, - "vcl::Window subclass declared as a return type from a method/function, should be wrapped in VclPtr.", + DiagnosticsEngine::Warning, + "VclPtr declared as a return type from a method/function, should be passed as a raw pointer.", functionDecl->getLocation()) << functionDecl->getSourceRange(); } diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index ab498f1183b3..95afb6acdbf4 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -76,8 +76,8 @@ protected: protected: friend class VclBuilder; - void set_action_area(const VclPtr<VclButtonBox> &xBox); - void set_content_area(const VclPtr<VclBox> &xBox); + void set_action_area(VclButtonBox* pBox); + void set_content_area(VclBox* pBox); public: explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG ); diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx index 265a83111d0e..f32c93269f80 100644 --- a/include/vcl/edit.hxx +++ b/include/vcl/edit.hxx @@ -237,7 +237,7 @@ public: virtual const Link& GetModifyHdl() const { return maModifyHdl; } virtual void SetUpdateDataHdl( const Link& rLink ) { maUpdateDataHdl = rLink; } - void SetSubEdit( const VclPtr<Edit>& pEdit ); + void SetSubEdit( Edit* pEdit ); Edit* GetSubEdit() const { return mpSubEdit; } boost::signals2::signal< void ( Edit* ) > autocompleteSignal; diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index e361ea9631fd..5bab0dec6eb5 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -2706,10 +2706,10 @@ void Edit::ClearModifyFlag() mbModified = false; } -void Edit::SetSubEdit( const VclPtr<Edit>& pEdit ) +void Edit::SetSubEdit( Edit* pEdit ) { mpSubEdit.disposeAndClear(); - mpSubEdit = pEdit; + mpSubEdit.set( pEdit ); if ( mpSubEdit ) { SetPointer( POINTER_ARROW ); // Nur das SubEdit hat den BEAM... diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 60aa87618f44..b7834993f8b4 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -509,14 +509,14 @@ Dialog::Dialog(vcl::Window* pParent, WinBits nStyle) ImplInit( pParent, nStyle ); } -void Dialog::set_action_area(const VclPtr<VclButtonBox> &xBox) +void Dialog::set_action_area(VclButtonBox* pBox) { - mpActionArea = xBox; + mpActionArea.set(pBox); } -void Dialog::set_content_area(const VclPtr<VclBox> &xBox) +void Dialog::set_content_area(VclBox* pBox) { - mpContentArea = xBox; + mpContentArea.set(pBox); } void Dialog::settingOptimalLayoutSize(Window *pBox) |