From 00a988896755dd9066d62892d38da0efe769493c Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Tue, 2 Feb 2016 12:59:17 +0100 Subject: tdf#97501: crash in SwDBManager fixed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Oliver Specht (cherry picked from commit 4426c20cf308f3bf7a2d3b33f9996687113c22e3) Reviewed-on: https://gerrit.libreoffice.org/26304 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/source/uibase/dbui/dbmgr.cxx | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index df149305d9f4..bfe28a3b1840 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -788,20 +788,26 @@ SwDBManager::SwDBManager(SwDoc* pDoc) SwDBManager::~SwDBManager() { + // copy required, m_DataSourceParams can be modifed while disposing components + std::vector> aCopiedConnections; for (auto & pParam : m_DataSourceParams) { if(pParam->xConnection.is()) { - try - { - uno::Reference 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 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 } } } -- cgit