connectivity/source/drivers/calc/CConnection.cxx | 10 +++++- connectivity/source/inc/calc/CConnection.hxx | 10 ++++-- dbaccess/source/core/api/RowSetCache.cxx | 16 ++++++---- include/sal/log-areas.dox | 1 include/unotools/closeveto.hxx | 3 + sw/source/uibase/dbui/dbmgr.cxx | 35 +++++++++++------------ unotools/source/misc/closeveto.cxx | 14 +++++---- 7 files changed, 54 insertions(+), 35 deletions(-)
New commits: commit 7368b6ca3f61e750765f42e97d0a00e10fcac516 Author: Michael Stahl <mst...@redhat.com> Date: Wed Apr 29 15:49:46 2015 +0200 rhbz#1213173: connectivity: Calc driver: prevent document being disposed ... by adding a XCloseListener that vetoes any attempt to close it. The Calc document can be opened by the user in the UI and closed again. Change-Id: Ied427b67274d925c911e516c0a50a4c0b2b18db9 diff --git a/connectivity/source/drivers/calc/CConnection.cxx b/connectivity/source/drivers/calc/CConnection.cxx index eb94e10..71a3c97 100644 --- a/connectivity/source/drivers/calc/CConnection.cxx +++ b/connectivity/source/drivers/calc/CConnection.cxx @@ -31,6 +31,7 @@ #include "calc/CPreparedStatement.hxx" #include "calc/CStatement.hxx" #include <unotools/pathoptions.hxx> +#include <unotools/closeveto.hxx> #include <connectivity/dbexception.hxx> #include <cppuhelper/exc_hlp.hxx> #include <comphelper/processfactory.hxx> @@ -165,13 +166,17 @@ Reference< XSpreadsheetDocument> OCalcConnection::acquireDoc() ::dbtools::throwGenericSQLException( sError, *this, aErrorDetails ); } osl_atomic_increment(&m_nDocCount); + m_pCloseListener.reset(new utl::CloseVeto(m_xDoc, true)); return m_xDoc; } void OCalcConnection::releaseDoc() { if ( osl_atomic_decrement(&m_nDocCount) == 0 ) - ::comphelper::disposeComponent( m_xDoc ); + { + m_pCloseListener.reset(); // dispose m_xDoc + m_xDoc.clear(); + } } void OCalcConnection::disposing() @@ -179,7 +184,8 @@ void OCalcConnection::disposing() ::osl::MutexGuard aGuard(m_aMutex); m_nDocCount = 0; - ::comphelper::disposeComponent( m_xDoc ); + m_pCloseListener.reset(); // dispose m_xDoc + m_xDoc.clear(); OConnection::disposing(); } diff --git a/connectivity/source/inc/calc/CConnection.hxx b/connectivity/source/inc/calc/CConnection.hxx index cda44ef..0171ac4 100644 --- a/connectivity/source/inc/calc/CConnection.hxx +++ b/connectivity/source/inc/calc/CConnection.hxx @@ -23,9 +23,11 @@ #include "file/FConnection.hxx" #include <com/sun/star/uno/DeploymentException.hpp> -namespace com { namespace sun { namespace star { namespace sheet { - class XSpreadsheetDocument; -} } } } +namespace com { namespace sun { namespace star { + namespace sheet { class XSpreadsheetDocument; } +} } } + +namespace utl { class CloseVeto; } namespace connectivity @@ -37,6 +39,8 @@ namespace connectivity { // the spreadsheet document: ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > m_xDoc; + /// close listener that vetoes so nobody disposes m_xDoc + ::std::unique_ptr< ::utl::CloseVeto> m_pCloseListener; OUString m_sPassword; OUString m_aFileName; oslInterlockedCount m_nDocCount; diff --git a/include/unotools/closeveto.hxx b/include/unotools/closeveto.hxx index 1079c35..fe55216 100644 --- a/include/unotools/closeveto.hxx +++ b/include/unotools/closeveto.hxx @@ -38,7 +38,8 @@ namespace utl class UNOTOOLS_DLLPUBLIC CloseVeto { public: - CloseVeto( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_closeable ); + CloseVeto( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_closeable, + bool bHasOwnership = false); ~CloseVeto(); private: diff --git a/unotools/source/misc/closeveto.cxx b/unotools/source/misc/closeveto.cxx index 290a18c..b33ef29 100644 --- a/unotools/source/misc/closeveto.cxx +++ b/unotools/source/misc/closeveto.cxx @@ -51,8 +51,8 @@ namespace utl class CloseListener_Impl : public CloseListener_Base { public: - CloseListener_Impl() - :m_bHasOwnership( false ) + CloseListener_Impl(bool const bHasOwnership) + : m_bHasOwnership(bHasOwnership) { } @@ -107,12 +107,13 @@ namespace utl namespace { - void lcl_init( CloseVeto_Data& i_data, const Reference< XInterface >& i_closeable ) + void lcl_init( CloseVeto_Data& i_data, const Reference< XInterface >& i_closeable, + bool const hasOwnership) { i_data.xCloseable.set( i_closeable, UNO_QUERY ); ENSURE_OR_RETURN_VOID( i_data.xCloseable.is(), "CloseVeto: the component is not closeable!" ); - i_data.pListener = new CloseListener_Impl; + i_data.pListener = new CloseListener_Impl(hasOwnership); i_data.xCloseable->addCloseListener( i_data.pListener.get() ); } @@ -138,10 +139,11 @@ namespace utl } //= CloseVeto - CloseVeto::CloseVeto( const Reference< XInterface >& i_closeable ) + CloseVeto::CloseVeto(const Reference< XInterface >& i_closeable, + bool const hasOwnership) : m_xData(new CloseVeto_Data) { - lcl_init(*m_xData, i_closeable); + lcl_init(*m_xData, i_closeable, hasOwnership); } CloseVeto::~CloseVeto() commit 7259901b25974c00c8f0ce8acb91096858cfff53 Author: Michael Stahl <mst...@redhat.com> Date: Wed Apr 29 13:14:53 2015 +0200 dbaccess: log exception messages in ORowSetCache Change-Id: I1c76d4ce91d1f22d88106918ab139b17f6f017f0 diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index f4baf90..2daf081 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -132,7 +132,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } catch(const Exception& ex) { - (void)ex; + SAL_WARN("dbaccess.core", "ORowSetCache: exception: " << ex.Message); } try { @@ -142,7 +142,7 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } catch(const SQLException& e) { - (void)e; + SAL_WARN("dbaccess.core", "ORowSetCache: exception: " << e.Message); } // check if all keys of the updateable table are fetched @@ -187,8 +187,9 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, m_aKeyColumns = pCursor->getJoinedKeyColumns(); return; } - catch(const Exception&) + catch (const Exception& e) { + SAL_WARN("dbaccess.core", "ORowSetCache: exception: " << e.Message); } m_pCacheSet = NULL; m_xCacheSet.clear(); @@ -227,8 +228,9 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } } } - catch(Exception&) + catch (Exception const& e) { + SAL_WARN("dbaccess.core", "ORowSetCache: exception: " << e.Message); } } @@ -255,8 +257,9 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, } } } - catch(const SQLException&) + catch (const SQLException& e) { + SAL_WARN("dbaccess.core", "ORowSetCache: exception: " << e.Message); bNeedKeySet = true; } @@ -336,8 +339,9 @@ ORowSetCache::ORowSetCache(const Reference< XResultSet >& _xRs, if(bNoInsert) m_nPrivileges |= ~Privilege::INSERT; // remove the insert privilege } - catch(const SQLException&) + catch (const SQLException& e) { + SAL_WARN("dbaccess.core", "ORowSetCache: exception: " << e.Message); // we couldn't create a keyset here so we have to create a static cache if ( m_pCacheSet ) m_pCacheSet = NULL; diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox index dcce17b..461fb78 100644 --- a/include/sal/log-areas.dox +++ b/include/sal/log-areas.dox @@ -475,6 +475,7 @@ certain functionality. @section dbaccess @li @c dbaccess +@li @c dbaccess.core @li @c dbaccess.ui @li @c dbaccess.ui.OGeneralPage commit a226bf71316847bdbface79567bc7290d2cedc03 Author: Michael Stahl <mst...@redhat.com> Date: Wed Apr 29 13:05:56 2015 +0200 sw: log exception messages in dbmgr.cxx Change-Id: I66e7b778a681e6f5ee7b0dd051bb52a1538c0645 diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 299eee2..e2e4bfe 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -124,6 +124,7 @@ #include <swcrsr.hxx> #include <swevent.hxx> #include <osl/file.hxx> +#include <sal/log.hxx> #include <swabstdlg.hxx> #include <fmthdft.hxx> #include <envelp.hrc> @@ -402,11 +403,11 @@ bool SwDBManager::MergeNew( const SwMergeDescriptor& rMergeDesc, vcl::Window* pP pImpl->pMergeData->CheckEndOfDB(); } } - catch(const Exception&) + catch (const Exception& e) { pImpl->pMergeData->bEndOfDB = true; pImpl->pMergeData->CheckEndOfDB(); - OSL_FAIL("exception in MergeNew()"); + SAL_WARN("sw.mailmerge", "exception in MergeNew(): " << e.Message); } uno::Reference<XDataSource> xSource = SwDBManager::getDataSourceAsParent(xConnection,aData.sDataSource); @@ -1592,9 +1593,9 @@ sal_uLong SwDBManager::GetColumnFmt( const OUString& rDBName, { xCols = xColsSupp->getColumns(); } - catch(const Exception&) + catch (const Exception& e) { - OSL_FAIL("Exception in getColumns()"); + SAL_WARN("sw.mailmerge", "Exception in getColumns(): " << e.Message); } if(!xCols.is() || !xCols->hasByName(rColNm)) return nRet; @@ -1682,16 +1683,16 @@ sal_uLong SwDBManager::GetColumnFmt( uno::Reference< XDataSource> xSource, nRet = nFmt; bUseDefault = false; } - catch(const Exception&) + catch (const Exception& e) { - OSL_FAIL("illegal number format key"); + SAL_WARN("sw.mailmerge", "illegal number format key: " << e.Message); } } } } catch(const Exception&) { - OSL_FAIL("no FormatKey property found"); + SAL_WARN("sw.mailmerge", "no FormatKey property found"); } if(bUseDefault) nRet = getDefaultNumberFormat(xColumn, xDocNumberFormatTypes, aLocale); @@ -1806,9 +1807,9 @@ uno::Reference< sdbcx::XColumnsSupplier> SwDBManager::GetColumnSupplier(uno::Ref xRowSet->execute(); xRet = Reference<XColumnsSupplier>( xRowSet, UNO_QUERY ); } - catch(const uno::Exception&) + catch (const uno::Exception& e) { - OSL_FAIL("Exception in SwDBManager::GetColumnSupplier"); + SAL_WARN("sw.mailmerge", "Exception in SwDBManager::GetColumnSupplier: " << e.Message); } return xRet; @@ -1873,9 +1874,9 @@ OUString SwDBManager::GetDBField(uno::Reference<XPropertySet> xColumnProps, } } } - catch(const Exception&) + catch (const Exception& e) { - OSL_FAIL("exception caught"); + SAL_WARN("sw.mailmerge", "exception caught: " << e.Message); } } @@ -2860,9 +2861,9 @@ void SwDBManager::InsertText(SwWrtShell& rSh, { pDlg->DataToDoc( aSelection , xSource, xConnection, xResSet); } - catch(const Exception&) + catch (const Exception& e) { - OSL_FAIL("exception caught"); + SAL_WARN("sw.mailmerge", "exception caught: " << e.Message); } } } @@ -2878,9 +2879,9 @@ uno::Reference<XDataSource> SwDBManager::getDataSourceAsParent(const uno::Refere if ( !xSource.is() ) xSource = getDataSource(_sDataSourceName, ::comphelper::getProcessComponentContext()); } - catch(const Exception&) + catch (const Exception& e) { - OSL_FAIL("exception in getDataSourceAsParent caught"); + SAL_WARN("sw.mailmerge", "exception caught in getDataSourceAsParent(): " << e.Message); } return xSource; } @@ -2917,9 +2918,9 @@ uno::Reference<XResultSet> SwDBManager::createCursor(const OUString& _sDataSourc } } } - catch(const Exception&) + catch (const Exception& e) { - OSL_FAIL("Caught exception while creating a new RowSet!"); + SAL_WARN("sw.mailmerge", "Caught exception while creating a new RowSet: " << e.Message); } return xResultSet; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits