diff options
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 26 |
1 files 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<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 } } } |