[Libreoffice-commits] core.git: sw/source

Oliver Specht oliver.specht at cib.de
Wed Feb 3 07:05:10 UTC 2016


 sw/source/uibase/dbui/dbmgr.cxx |   26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

New commits:
commit 4426c20cf308f3bf7a2d3b33f9996687113c22e3
Author: Oliver Specht <oliver.specht at cib.de>
Date:   Tue Feb 2 12:59:17 2016 +0100

    tdf#97501: crash in SwDBManager fixed
    
    copy the connections to a temp container and iterate that because
    disposing connections changes the data source params container
    
    Change-Id: I06c59a19a6bcf97a541b32481d1d2a63f5c34032
    Reviewed-on: https://gerrit.libreoffice.org/22027
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Oliver Specht <oliver.specht at cib.de>

diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 864e45b..0aea9c9 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -771,20 +771,26 @@ SwDBManager::SwDBManager(SwDoc* pDoc)
 
 SwDBManager::~SwDBManager()
 {
+    // copy required, m_DataSourceParams can be modifed while disposing components
+    std::vector<uno::Reference<sdbc::XConnection>> aCopiedConnections;
     for (auto & pParam : m_DataSourceParams)
     {
         if(pParam->xConnection.is())
         {
-            try
-            {
-                uno::Reference<lang::XComponent> xComp(pParam->xConnection, uno::UNO_QUERY);
-                if(xComp.is())
-                    xComp->dispose();
-            }
-            catch(const uno::RuntimeException&)
-            {
-                //may be disposed already since multiple entries may have used the same connection
-            }
+            aCopiedConnections.push_back(pParam->xConnection);
+        }
+    }
+    for (auto & xConnection : aCopiedConnections)
+    {
+        try
+        {
+            uno::Reference<lang::XComponent> xComp(xConnection, uno::UNO_QUERY);
+            if(xComp.is())
+                xComp->dispose();
+        }
+        catch(const uno::RuntimeException&)
+        {
+            //may be disposed already since multiple entries may have used the same connection
         }
     }
 }


More information about the Libreoffice-commits mailing list