[Libreoffice-commits] core.git: 7 commits - connectivity/source dbaccess/qa dbaccess/source sc/qa test/source

Michael Stahl mstahl at redhat.com
Tue Oct 21 06:15:00 PDT 2014


 connectivity/source/drivers/firebird/Connection.cxx          |    8 +++-
 connectivity/source/drivers/firebird/DatabaseMetaData.cxx    |    5 +-
 connectivity/source/drivers/firebird/DatabaseMetaData.hxx    |    4 --
 connectivity/source/drivers/firebird/PreparedStatement.cxx   |    6 +--
 connectivity/source/drivers/firebird/ResultSet.hxx           |    1 
 connectivity/source/drivers/firebird/ResultSetMetaData.hxx   |    2 -
 connectivity/source/drivers/firebird/Statement.cxx           |    4 +-
 connectivity/source/drivers/firebird/StatementCommonBase.cxx |    1 
 connectivity/source/drivers/firebird/StatementCommonBase.hxx |    5 --
 dbaccess/qa/unit/firebird.cxx                                |    4 ++
 dbaccess/source/core/dataaccess/ModelImpl.cxx                |   10 ++---
 sc/qa/extras/sctablesheetobj.cxx                             |   22 ++++++++---
 sc/qa/extras/sctablesheetsobj.cxx                            |    4 --
 test/source/sheet/xspreadsheets2.cxx                         |    8 +++-
 14 files changed, 52 insertions(+), 32 deletions(-)

New commits:
commit 820e64f96615f46ac97762357d0369615967dbdb
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Oct 21 14:03:05 2014 +0200

    connectivity: firebird: fix temp directory leak
    
    Dispose the dbaccess document, and recursively delete the temp directory
    in Connection::dispose().
    
    Change-Id: Id283289e44b8ca09b88da19920da7f27b551aa7e

diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx
index 40ed35a..dfda365 100644
--- a/connectivity/source/drivers/firebird/Connection.cxx
+++ b/connectivity/source/drivers/firebird/Connection.cxx
@@ -55,6 +55,7 @@
 #include <comphelper/processfactory.hxx>
 #include <comphelper/storagehelper.hxx>
 #include <unotools/tempfile.hxx>
+#include <unotools/localfilehelper.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 
 using namespace connectivity::firebird;
@@ -166,7 +167,6 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV
             bIsNewDatabase = !m_xEmbeddedStorage->hasElements();
 
             m_pExtractedFDBFile.reset(new ::utl::TempFile(NULL, true));
-            m_pExtractedFDBFile->EnableKillingFile();
             m_sFirebirdURL = m_pExtractedFDBFile->GetFileName() + "/firebird.fdb";
 
             SAL_INFO("connectivity.firebird", "Temporary .fdb location:  " << m_sFirebirdURL);
@@ -785,6 +785,12 @@ void Connection::disposing()
     dispose_ChildImpl();
     cppu::WeakComponentImplHelperBase::disposing();
     m_xDriver.clear();
+
+    if (m_pExtractedFDBFile)
+    {
+        ::utl::removeTree(m_pExtractedFDBFile->GetURL());
+        m_pExtractedFDBFile.reset();
+    }
 }
 
 void Connection::disposeStatements()
diff --git a/dbaccess/qa/unit/firebird.cxx b/dbaccess/qa/unit/firebird.cxx
index 61c2a3c..424c0cd 100644
--- a/dbaccess/qa/unit/firebird.cxx
+++ b/dbaccess/qa/unit/firebird.cxx
@@ -54,6 +54,8 @@ void FirebirdTest::testEmptyDBConnection()
         getDocumentForFileName("firebird_empty.odb");
 
     getConnectionForDocument(xDocument);
+
+    closeDocument(uno::Reference<lang::XComponent>(xDocument, uno::UNO_QUERY));
 }
 
 /**
@@ -93,6 +95,8 @@ void FirebirdTest::testIntegerDatabase()
         xRow->getString(xColumnLocate->findColumn("_VARCHAR")));
 
     CPPUNIT_ASSERT(!xResultSet->next()); // Should only be one row
+
+    closeDocument(uno::Reference<lang::XComponent>(xDocument, uno::UNO_QUERY));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(FirebirdTest);
commit a2e4d4329bc3913a198c25c428faedef02f36681
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Oct 21 13:33:50 2014 +0200

    connectivity: firebird: use Reference for Connection where appropriate
    
    ODatabaseMetaData and OResultSetMetaData apparently have life-times
    independent of their creating object, so they need to own the
    Connection too.
    
    Change-Id: Idee28a96e318ca4b3d804084d609737a7fc75862

diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index 52a96ef..c1a970f 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
@@ -46,7 +46,8 @@ using namespace com::sun::star::sdbc;
 ODatabaseMetaData::ODatabaseMetaData(Connection* _pCon)
 : m_pConnection(_pCon)
 {
-    OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
+    SAL_WARN_IF(!m_pConnection.is(), "connectivity.firebird",
+            "ODatabaseMetaData::ODatabaseMetaData: No connection set!");
 }
 
 ODatabaseMetaData::~ODatabaseMetaData()
@@ -832,7 +833,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates()
 uno::Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection()
     throw(SQLException, RuntimeException, std::exception)
 {
-    return uno::Reference< XConnection >(m_pConnection);
+    return uno::Reference<XConnection>(m_pConnection.get());
 }
 
 // here follow all methods which return a resultset
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.hxx b/connectivity/source/drivers/firebird/DatabaseMetaData.hxx
index 882bfaf..abb4c1d 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.hxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.hxx
@@ -37,11 +37,9 @@ namespace connectivity
 
         class ODatabaseMetaData : public ODatabaseMetaData_BASE
         {
-            Connection*    m_pConnection;
+            ::rtl::Reference<Connection> m_pConnection;
         public:
 
-            inline Connection* getOwnConnection() const { return m_pConnection; }
-
             ODatabaseMetaData(Connection* _pCon);
             virtual ~ODatabaseMetaData();
 
diff --git a/connectivity/source/drivers/firebird/ResultSetMetaData.hxx b/connectivity/source/drivers/firebird/ResultSetMetaData.hxx
index 494979e..d8ad569 100644
--- a/connectivity/source/drivers/firebird/ResultSetMetaData.hxx
+++ b/connectivity/source/drivers/firebird/ResultSetMetaData.hxx
@@ -38,7 +38,7 @@ namespace connectivity
         class OResultSetMetaData :  public  OResultSetMetaData_BASE
         {
         protected:
-            Connection*     m_pConnection;
+            ::rtl::Reference<Connection> m_pConnection;
             XSQLDA*         m_pSqlda;
 
             virtual ~OResultSetMetaData();
commit 137131b1e0c81bb948e563f831cfe9e6ebfb1b3f
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Oct 21 13:20:18 2014 +0200

    connectivity: firebird: fix Connection leak in OStatementCommonBase
    
    bin/refcount_leak.py was very helpful here.
    
    Change-Id: I61dc57408cf1533f733c08b701884851ec6afb8d

diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index 0654407..ac37c52 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -152,7 +152,7 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData()
     ensurePrepared();
 
     if(!m_xMetaData.is())
-        m_xMetaData = new OResultSetMetaData(m_pConnection, m_pOutSqlda);
+        m_xMetaData = new OResultSetMetaData(m_pConnection.get(), m_pOutSqlda);
 
     return m_xMetaData;
 }
@@ -239,7 +239,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection()
     MutexGuard aGuard( m_aMutex );
     checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
 
-    return Reference< XConnection >(m_pConnection);
+    return Reference<XConnection>(m_pConnection.get());
 }
 
 sal_Bool SAL_CALL OPreparedStatement::execute()
@@ -282,7 +282,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
         evaluateStatusVector(m_statusVector, "isc_dsql_execute", *this);
     }
 
-    m_xResultSet = new OResultSet(m_pConnection,
+    m_xResultSet = new OResultSet(m_pConnection.get(),
                                   m_aMutex,
                                   uno::Reference< XInterface >(*this),
                                   m_aStatementHandle,
diff --git a/connectivity/source/drivers/firebird/ResultSet.hxx b/connectivity/source/drivers/firebird/ResultSet.hxx
index 90c2b9f..dbb971a 100644
--- a/connectivity/source/drivers/firebird/ResultSet.hxx
+++ b/connectivity/source/drivers/firebird/ResultSet.hxx
@@ -79,6 +79,7 @@ namespace connectivity
             sal_Int32 m_nResultSetConcurrency;
 
         protected:
+            // Connection kept alive by m_xStatement
             Connection* m_pConnection;
             ::osl::Mutex& m_rMutex;
             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& m_xStatement;
diff --git a/connectivity/source/drivers/firebird/Statement.cxx b/connectivity/source/drivers/firebird/Statement.cxx
index 4247894..59e5ff8 100644
--- a/connectivity/source/drivers/firebird/Statement.cxx
+++ b/connectivity/source/drivers/firebird/Statement.cxx
@@ -125,7 +125,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
     if (aErr)
         SAL_WARN("connectivity.firebird", "isc_dsql_execute failed");
 
-    m_xResultSet = new OResultSet(m_pConnection,
+    m_xResultSet = new OResultSet(m_pConnection.get(),
                                   m_aMutex,
                                   uno::Reference< XInterface >(*this),
                                   m_aStatementHandle,
@@ -162,7 +162,7 @@ uno::Reference< XConnection > SAL_CALL OStatement::getConnection()
     MutexGuard aGuard(m_aMutex);
     checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
 
-    return uno::Reference< XConnection >(m_pConnection);
+    return uno::Reference<XConnection>(m_pConnection.get());
 }
 
 Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
index 5daa56d..e6a67e4 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
@@ -51,7 +51,6 @@ OStatementCommonBase::OStatementCommonBase(Connection* _pConnection)
       m_aStatementHandle( 0 ),
       rBHelper(OStatementCommonBase_Base::rBHelper)
 {
-    m_pConnection->acquire();
 }
 
 OStatementCommonBase::~OStatementCommonBase()
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.hxx b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
index 3591d22..60ac915 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.hxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
@@ -60,7 +60,7 @@ namespace connectivity
 
             ::std::list< ::rtl::OUString>               m_aBatchList;
 
-            Connection*                                 m_pConnection;
+            ::rtl::Reference<Connection>                m_pConnection;
 
             ISC_STATUS_ARRAY                            m_statusVector;
             isc_stmt_handle                             m_aStatementHandle;
@@ -136,9 +136,6 @@ namespace connectivity
             // XCloseable
             virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 
-            // other methods
-            Connection* getOwnConnection() const { return m_pConnection;}
-
         };
     }
 }
commit 666ec98b7e10ca8acd891363587fd345373b3716
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Oct 20 21:50:23 2014 +0200

    dbaccess: surely the problem is that the storage could _not_ be committed?
    
    Change-Id: I03e7e09e185e9cb25868c86de0b402b89e7f5d75

diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index 72cc6b2..b756bc8 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -54,6 +54,7 @@
 #include <tools/debug.hxx>
 #include <tools/diagnose_ex.h>
 #include <osl/diagnose.h>
+#include <sal/log.hxx>
 #include <tools/errcode.hxx>
 #include <tools/urlobj.hxx>
 #include <unotools/sharedunocomponent.hxx>
@@ -796,12 +797,9 @@ Reference< XSingleServiceFactory > ODatabaseModelImpl::createStorageFactory() co
 void ODatabaseModelImpl::commitRootStorage()
 {
     Reference< XStorage > xStorage( getOrCreateRootStorage() );
-#if OSL_DEBUG_LEVEL > 0
-    bool bSuccess =
-#endif
-    commitStorageIfWriteable_ignoreErrors( xStorage );
-    OSL_ENSURE( bSuccess || !xStorage.is(),
-        "ODatabaseModelImpl::commitRootStorage: could commit the storage!" );
+    bool bSuccess = commitStorageIfWriteable_ignoreErrors( xStorage );
+    SAL_WARN_IF(!bSuccess && xStorage.is(), "dbaccess",
+        "ODatabaseModelImpl::commitRootStorage: could not commit the storage!");
 }
 
 Reference< XStorage > ODatabaseModelImpl::getOrCreateRootStorage()
commit ed45c87896de74048708d51c050ecd42c9f4a0a0
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Oct 20 21:08:54 2014 +0200

    sc: fix temp file leak in ScTableSheetsObj
    
    Change-Id: Iff838c97c1cf633f99e75a169eeb8bb324d4a32a

diff --git a/test/source/sheet/xspreadsheets2.cxx b/test/source/sheet/xspreadsheets2.cxx
index aa010d3..17c5f01 100644
--- a/test/source/sheet/xspreadsheets2.cxx
+++ b/test/source/sheet/xspreadsheets2.cxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/container/XNameContainer.hpp>
 #include <com/sun/star/table/CellVertJustify.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
 
 #include <rtl/ustring.hxx>
 #include "cppunit/extensions/HelperMacros.h"
@@ -48,6 +49,11 @@ XSpreadsheets2::XSpreadsheets2():
 
 XSpreadsheets2::~XSpreadsheets2()
 {
+    if (xDestDoc.is())
+    {
+        uno::Reference<util::XCloseable> xCloseable(xDestDoc, UNO_QUERY_THROW);
+        xCloseable->close(true);
+    }
 }
 
 void XSpreadsheets2::testImportedSheetNameAndIndex()
@@ -302,7 +308,7 @@ void XSpreadsheets2::importSheetToCopy()
     uno::Reference< container::XNameAccess> xSrcNameAccess(init(),UNO_QUERY_THROW);
     xSrcSheet = uno::Reference< sheet::XSpreadsheet >( xSrcNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
 
-    static uno::Reference< lang::XComponent > xDestComponent;
+    uno::Reference< lang::XComponent > xDestComponent;
     if (!xDestComponent.is())
     {
         xDestDoc = getDoc(aDestFileBase, xDestComponent);
commit d7806edcba5e1f9a09decdc95857310ea0a68244
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Oct 20 20:50:20 2014 +0200

    sc: remove duplicate test methods from ScTableSheetsObj
    
    Change-Id: I4b0798a08f650660d1b5daaa41c7ee3618fbab3a

diff --git a/sc/qa/extras/sctablesheetsobj.cxx b/sc/qa/extras/sctablesheetsobj.cxx
index 0d71349..6fdeace 100644
--- a/sc/qa/extras/sctablesheetsobj.cxx
+++ b/sc/qa/extras/sctablesheetsobj.cxx
@@ -19,7 +19,7 @@ using namespace css::uno;
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 13
+#define NUMBER_OF_TESTS 11
 
 class ScTableSheetsObj : public CalcUnoApiTest, public ::apitest::XSpreadsheets2, apitest::XNameContainer
 {
@@ -30,8 +30,6 @@ public:
     virtual void tearDown() SAL_OVERRIDE;
 
     CPPUNIT_TEST_SUITE(ScTableSheetsObj);
-    CPPUNIT_TEST(testImportValue);
-    CPPUNIT_TEST(testImportString);
     CPPUNIT_TEST(testImportedSheetNameAndIndex);
     CPPUNIT_TEST(testImportString);
     CPPUNIT_TEST(testImportValue);
commit 4548e98596996d996d03cfd0b8d6d76bc14d77e1
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Oct 20 20:44:22 2014 +0200

    sc: fix temp file leak in ScTableSheetObj
    
    Change-Id: If75573ffe565ec621aa6c9739cec71bc4b087c7a

diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx
index f64905f..fd9aa76 100644
--- a/sc/qa/extras/sctablesheetobj.cxx
+++ b/sc/qa/extras/sctablesheetobj.cxx
@@ -26,6 +26,9 @@ class ScTableSheetObj : public CalcUnoApiTest, apitest::XSearchable, apitest::XR
 public:
     ScTableSheetObj();
 
+    virtual void setUp() SAL_OVERRIDE;
+    virtual void tearDown() SAL_OVERRIDE;
+
     virtual uno::Reference< uno::XInterface > init() SAL_OVERRIDE;
 
     CPPUNIT_TEST_SUITE(ScTableSheetObj);
@@ -40,13 +43,9 @@ public:
     CPPUNIT_TEST_SUITE_END();
 
 private:
-    static sal_Int32 nTest;
-    static uno::Reference< lang::XComponent > mxComponent;
+    uno::Reference< lang::XComponent > mxComponent;
 };
 
-sal_Int32 ScTableSheetObj::nTest = 0;
-uno::Reference< lang::XComponent > ScTableSheetObj::mxComponent;
-
 ScTableSheetObj::ScTableSheetObj():
     CalcUnoApiTest("/sc/qa/extras/testdocuments"),
     apitest::XSearchable(OUString("test"), 4),
@@ -69,6 +68,19 @@ uno::Reference< uno::XInterface > ScTableSheetObj::init()
     return xSheet;
 }
 
+void ScTableSheetObj::setUp()
+{
+    CalcUnoApiTest::setUp();
+}
+
+void ScTableSheetObj::tearDown()
+{
+    closeDocument(mxComponent);
+    mxComponent.clear();
+
+    CalcUnoApiTest::tearDown();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTableSheetObj);
 
 }


More information about the Libreoffice-commits mailing list