diff options
-rw-r--r-- | UnoControls/source/controls/progressmonitor.cxx | 2 | ||||
-rw-r--r-- | UnoControls/source/controls/statusindicator.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/vclwidgets.cxx | 33 |
3 files changed, 28 insertions, 9 deletions
diff --git a/UnoControls/source/controls/progressmonitor.cxx b/UnoControls/source/controls/progressmonitor.cxx index 7016e347b716..1cb5695cc5ed 100644 --- a/UnoControls/source/controls/progressmonitor.cxx +++ b/UnoControls/source/controls/progressmonitor.cxx @@ -57,7 +57,7 @@ ProgressMonitor::ProgressMonitor( const css::uno::Reference< XComponentContext > m_xTopic_Bottom.set( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); m_xText_Bottom.set ( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); m_xButton.set ( rxContext->getServiceManager()->createInstanceWithContext( BUTTON_SERVICENAME, rxContext ), UNO_QUERY ); - m_xProgressBar = VclPtr<ProgressBar>::Create(rxContext); + m_xProgressBar = new ProgressBar(rxContext); // ... cast controls to Reference< XControl > (for "setModel"!) ... css::uno::Reference< XControl > xRef_Topic_Top ( m_xTopic_Top , UNO_QUERY ); diff --git a/UnoControls/source/controls/statusindicator.cxx b/UnoControls/source/controls/statusindicator.cxx index 8df082e8f12d..a9c901dad70a 100644 --- a/UnoControls/source/controls/statusindicator.cxx +++ b/UnoControls/source/controls/statusindicator.cxx @@ -46,7 +46,7 @@ StatusIndicator::StatusIndicator( const css::uno::Reference< XComponentContext > // Create instances for fixedtext and progress ... m_xText.set( rxContext->getServiceManager()->createInstanceWithContext( FIXEDTEXT_SERVICENAME, rxContext ), UNO_QUERY ); - m_xProgressBar = VclPtr<ProgressBar>::Create(rxContext); + m_xProgressBar = new ProgressBar(rxContext); // ... cast controls to css::uno::Reference< XControl > and set model ... // ( ProgressBar has no model !!! ) css::uno::Reference< XControl > xTextControl ( m_xText , UNO_QUERY ); diff --git a/compilerplugins/clang/vclwidgets.cxx b/compilerplugins/clang/vclwidgets.cxx index bb0ad54c8051..e90e40fe6e39 100644 --- a/compilerplugins/clang/vclwidgets.cxx +++ b/compilerplugins/clang/vclwidgets.cxx @@ -825,19 +825,38 @@ bool VCLWidgets::VisitCXXConstructExpr( const CXXConstructExpr* constructExpr ) if (ignoreLocation(constructExpr)) { return true; } - StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(constructExpr->getLocStart())); - if (aFileName == SRCDIR "/include/vcl/vclptr.hxx") - return true; if (constructExpr->getConstructionKind() != CXXConstructExpr::CK_Complete) { return true; } const CXXConstructorDecl* pConstructorDecl = constructExpr->getConstructor(); const CXXRecordDecl* recordDecl = pConstructorDecl->getParent(); if (isDerivedFromVclReferenceBase(recordDecl)) { - report( - DiagnosticsEngine::Warning, - "Calling constructor of a VclReferenceBase-derived type directly; all such creation should go via VclPtr<>::Create", - constructExpr->getExprLoc()); + StringRef aFileName = compiler.getSourceManager().getFilename(compiler.getSourceManager().getSpellingLoc(constructExpr->getLocStart())); + if (aFileName != SRCDIR "/include/vcl/vclptr.hxx") { + report( + DiagnosticsEngine::Warning, + "Calling constructor of a VclReferenceBase-derived type directly; all such creation should go via VclPtr<>::Create", + constructExpr->getExprLoc()); + } + } else if (auto d = dyn_cast<ClassTemplateSpecializationDecl>(recordDecl)) { + if (d->getTemplateArgs().size() == 1) { + auto check = loplugin::DeclCheck(recordDecl); + if ((check.Class("ScopedVclPtr").GlobalNamespace() + || check.Class("ScopedVclPtrInstance").GlobalNamespace() + || check.Class("VclPtr").GlobalNamespace() + || check.Class("VclPtrInstance").GlobalNamespace())) + { + auto t = d->getTemplateArgs()[0].getAsType(); + if (!containsVclReferenceBaseSubclass(t)) { + report( + DiagnosticsEngine::Warning, + ("constructing an instance of %0 where the argument" + " type %1 is not derived from VclReferenceBase"), + constructExpr->getExprLoc()) + << recordDecl << t << constructExpr->getSourceRange(); + } + } + } } return true; } |