[Libreoffice-commits] core.git: 2 commits - dbaccess/source framework/inc framework/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jan 29 11:20:08 UTC 2019


 dbaccess/source/core/dataaccess/datasource.cxx        |   13 ++++--
 framework/inc/classes/protocolhandlercache.hxx        |    6 +--
 framework/source/fwi/classes/protocolhandlercache.cxx |   35 +++++++++---------
 3 files changed, 30 insertions(+), 24 deletions(-)

New commits:
commit 48c6f4e0885976f9d8ccbffc5088f37bb5f1b9f0
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Jan 28 17:56:39 2019 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Jan 29 12:19:57 2019 +0100

    framework: avoid crashing in ~HandlerCFGAccess() in atexit()
    
    Commit d587931fba77246db3a2ccc6ab61ca77446d23f4 changed
    HandlerCache::s_pConfig to a unique_ptr, which may now crash on
    shutdown because it's a utl::ConfigItem and by atexit() time the
    configmgr is long gone.
    
    Due to the HandlerCache::m_nRefCount, the crash probably only happens
    in case of an unclean shutdown, but we don't know whether this can
    happen in practice or not, so just avoid crashing on shutdown.
    
    Change-Id: Ifd2b782aa5592c344d1bc85acaa434c3f2a69b60
    Reviewed-on: https://gerrit.libreoffice.org/67029
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

diff --git a/framework/inc/classes/protocolhandlercache.hxx b/framework/inc/classes/protocolhandlercache.hxx
index 7f5af88f342e..a23acb57bc39 100644
--- a/framework/inc/classes/protocolhandlercache.hxx
+++ b/framework/inc/classes/protocolhandlercache.hxx
@@ -93,11 +93,11 @@ class FWI_DLLPUBLIC HandlerCache final
     private:
 
         /// list of all registered handler registered by her uno implementation names
-        static std::unique_ptr<HandlerHash> m_pHandler;
+        static std::unique_ptr<HandlerHash> s_pHandler;
         /// maps URL pattern to handler names
-        static std::unique_ptr<PatternHash> m_pPattern;
+        static std::unique_ptr<PatternHash> s_pPattern;
         /// informs about config updates
-        static std::unique_ptr<HandlerCFGAccess> m_pConfig;
+        static HandlerCFGAccess* s_pConfig;
         /// ref count to construct/destruct internal member lists on demand by using singleton mechanism
         static sal_Int32 m_nRefCount;
 
diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx
index 41a8d5005602..0c23aaa80f37 100644
--- a/framework/source/fwi/classes/protocolhandlercache.cxx
+++ b/framework/source/fwi/classes/protocolhandlercache.cxx
@@ -73,10 +73,10 @@ PatternHash::const_iterator findPatternKey(PatternHash const * hash, const OUStr
                 That means it use two static member list to hold all necessary information
                 and a ref count mechanism to create/destroy it on demand.
  */
-std::unique_ptr<HandlerHash> HandlerCache::m_pHandler;
-std::unique_ptr<PatternHash> HandlerCache::m_pPattern;
+std::unique_ptr<HandlerHash> HandlerCache::s_pHandler;
+std::unique_ptr<PatternHash> HandlerCache::s_pPattern;
 sal_Int32    HandlerCache::m_nRefCount = 0;
-std::unique_ptr<HandlerCFGAccess> HandlerCache::m_pConfig;
+HandlerCFGAccess* HandlerCache::s_pConfig = nullptr;
 
 /**
     @short      ctor of the cache of all registered protocol handler
@@ -91,11 +91,11 @@ HandlerCache::HandlerCache()
 
     if (m_nRefCount==0)
     {
-        m_pHandler.reset(new HandlerHash);
-        m_pPattern.reset(new PatternHash);
-        m_pConfig.reset(new HandlerCFGAccess(PACKAGENAME_PROTOCOLHANDLER));
-        m_pConfig->read(*m_pHandler, *m_pPattern);
-        m_pConfig->setCache(this);
+        s_pHandler.reset(new HandlerHash);
+        s_pPattern.reset(new PatternHash);
+        s_pConfig = new HandlerCFGAccess(PACKAGENAME_PROTOCOLHANDLER);
+        s_pConfig->read(*s_pHandler, *s_pPattern);
+        s_pConfig->setCache(this);
     }
 
     ++m_nRefCount;
@@ -112,11 +112,12 @@ HandlerCache::~HandlerCache()
 
     if( m_nRefCount==1)
     {
-        m_pConfig->setCache(nullptr);
+        s_pConfig->setCache(nullptr);
 
-        m_pConfig.reset();
-        m_pHandler.reset();
-        m_pPattern.reset();
+        delete s_pConfig;
+        s_pConfig = nullptr;
+        s_pHandler.reset();
+        s_pPattern.reset();
     }
 
     --m_nRefCount;
@@ -133,10 +134,10 @@ bool HandlerCache::search( const OUString& sURL, ProtocolHandler* pReturn ) cons
 
     SolarMutexGuard aGuard;
 
-    PatternHash::const_iterator pItem = findPatternKey(m_pPattern.get(), sURL);
-    if (pItem!=m_pPattern->end())
+    PatternHash::const_iterator pItem = findPatternKey(s_pPattern.get(), sURL);
+    if (pItem != s_pPattern->end())
     {
-        *pReturn = (*m_pHandler)[pItem->second];
+        *pReturn = (*s_pHandler)[pItem->second];
         bFound = true;
     }
 
@@ -158,8 +159,8 @@ void HandlerCache::takeOver(std::unique_ptr<HandlerHash> pHandler, std::unique_p
 {
     SolarMutexGuard aGuard;
 
-    m_pHandler = std::move(pHandler);
-    m_pPattern = std::move(pPattern);
+    s_pHandler = std::move(pHandler);
+    s_pPattern = std::move(pPattern);
 }
 
 /**
commit 577a9708ea9594d60b66c1c71d24175c66d24096
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Jan 28 17:14:03 2019 +0100
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Tue Jan 29 12:19:43 2019 +0100

    dbaccess: don't try to migrate read-only file
    
    It's going to throw IOException anyway.
    
    This fixes CppunitTest_dbaccess_hsqldb_test on read-only file system.
    
    Change-Id: Ifc8a4791ab9a1a8d3e0f1e67d65e10dac458147c
    Reviewed-on: https://gerrit.libreoffice.org/67028
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index f970b9e95100..9d80a1bf3a56 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -605,6 +605,7 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString
     bool bNeedMigration = false;
     if(m_pImpl->m_sConnectURL == "sdbc:embedded:hsqldb")
     {
+        Reference<XStorage> const xRootStorage = m_pImpl->getOrCreateRootStorage();
         OUString sMigrEnvVal;
         osl_getEnvironment(OUString("DBACCESS_HSQL_MIGRATION").pData,
             &sMigrEnvVal.pData);
@@ -612,14 +613,18 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString
             bNeedMigration = true;
         else
         {
-            MigrationWarnDialog aWarnDlg(GetFrameWeld(m_pImpl->getModel_noCreate()));
-            bNeedMigration = aWarnDlg.run() == RET_OK;
+            Reference<XPropertySet> const xPropSet(xRootStorage, UNO_QUERY_THROW);
+            sal_Int32 nOpenMode(0);
+            if ((xPropSet->getPropertyValue("OpenMode") >>= nOpenMode)
+                && (nOpenMode & css::embed::ElementModes::WRITE))
+            {
+                MigrationWarnDialog aWarnDlg(GetFrameWeld(m_pImpl->getModel_noCreate()));
+                bNeedMigration = aWarnDlg.run() == RET_OK;
+            }
         }
         if (bNeedMigration)
         {
             // back up content xml file if migration was successful
-            Reference<XStorage> xRootStorage = m_pImpl->getOrCreateRootStorage();
-
             constexpr char BACKUP_XML_NAME[] = "content_before_migration.xml";
             try
             {


More information about the Libreoffice-commits mailing list