[Libreoffice-commits] core.git: compilerplugins/clang dbaccess/source

Stephan Bergmann sbergman at redhat.com
Fri Dec 1 15:34:43 UTC 2017


 compilerplugins/clang/refcounting.cxx                |    3 +++
 compilerplugins/clang/test/refcounting.cxx           |    5 +++++
 dbaccess/source/core/dataaccess/databasedocument.hxx |    3 ++-
 3 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 5066377bbeab1000f31e3fa689bad2ff8bf35295
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Dec 1 11:24:04 2017 +0100

    Don't prevent ODatabaseDocument refcount from dropping to zero
    
    ...preventing the dtor from ever being called.  (DocumentEvents forwards its
    acquire/release calls to its m_pData->rParent, i.e., the ODatabaseDocument, for
    better or worse.)  This caused ODatabaseDocument instances to be leaked during
    e.g. JunitTest_dbaccess_complex.  Regression introduced with
    de2ac128da025502c533f8cede5862e054dd9c44 "loplugin:useuniqueptr in dbaccess".
    
    Change-Id: Ida073c7e576b88e0d1d1a90253445e946e6eac99
    Reviewed-on: https://gerrit.libreoffice.org/45652
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
index 8091fb3ee0cd..58a9884ede0d 100644
--- a/compilerplugins/clang/refcounting.cxx
+++ b/compilerplugins/clang/refcounting.cxx
@@ -479,6 +479,8 @@ bool RefCounting::VisitFieldDecl(const FieldDecl * fieldDecl) {
             << fieldDecl->getSourceRange();
     }
 
+// Not in general (dbaccess::DocumentEvents, dbaccess/source/core/dataaccess/databasedocument.hxx):
+#if 0
     if (!firstTemplateParamType.isNull() && containsXInterfaceSubclass(firstTemplateParamType))
     {
         report(
@@ -490,6 +492,7 @@ bool RefCounting::VisitFieldDecl(const FieldDecl * fieldDecl) {
             << fieldDecl->getParent()
             << fieldDecl->getSourceRange();
     }
+#endif
 
     checkUnoReference(
         fieldDecl->getType(), fieldDecl,
diff --git a/compilerplugins/clang/test/refcounting.cxx b/compilerplugins/clang/test/refcounting.cxx
index 48fb94c694c4..4bcb03e2eef6 100644
--- a/compilerplugins/clang/test/refcounting.cxx
+++ b/compilerplugins/clang/test/refcounting.cxx
@@ -13,11 +13,16 @@
 #include <boost/intrusive_ptr.hpp>
 #include <com/sun/star/uno/XInterface.hpp>
 
+// expected-no-diagnostics
+
 struct Foo
 {
+// Not in general (dbaccess::DocumentEvents, dbaccess/source/core/dataaccess/databasedocument.hxx):
+#if 0
     std::unique_ptr<css::uno::XInterface> m_foo1; // expected-error {{XInterface subclass 'com::sun::star::uno::XInterface' being managed via smart pointer, should be managed via uno::Reference, parent is 'Foo' [loplugin:refcounting]}}
     std::shared_ptr<css::uno::XInterface> m_foo2; // expected-error {{XInterface subclass 'com::sun::star::uno::XInterface' being managed via smart pointer, should be managed via uno::Reference, parent is 'Foo' [loplugin:refcounting]}}
     boost::intrusive_ptr<css::uno::XInterface> m_foo3; // expected-error {{XInterface subclass 'com::sun::star::uno::XInterface' being managed via smart pointer, should be managed via uno::Reference, parent is 'Foo' [loplugin:refcounting]}}
+#endif
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/dbaccess/source/core/dataaccess/databasedocument.hxx b/dbaccess/source/core/dataaccess/databasedocument.hxx
index 8f9c8693433b..9479511367ce 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.hxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.hxx
@@ -22,6 +22,7 @@
 #include <sal/config.h>
 
 #include <map>
+#include <memory>
 
 #include <ModelImpl.hxx>
 #include "documenteventnotifier.hxx"
@@ -171,7 +172,7 @@ class ODatabaseDocument :public ModelDependentComponent             // ModelDepe
     ::comphelper::OInterfaceContainerHelper2                                                    m_aCloseListener;
     ::comphelper::OInterfaceContainerHelper2                                                    m_aStorageListeners;
 
-    rtl::Reference<DocumentEvents>                                                              m_pEventContainer;
+    std::unique_ptr<DocumentEvents>                                                             m_pEventContainer;
     ::rtl::Reference< DocumentEventExecutor >                                                   m_pEventExecutor;
     DocumentEventNotifier                                                                       m_aEventNotifier;
 


More information about the Libreoffice-commits mailing list