summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-01-15 21:47:44 +0100
committerMichael Stahl <mstahl@redhat.com>2015-01-15 21:54:48 +0100
commit0ffa3abc7d6c0437ece30cfb1430d28ffcc9f5c1 (patch)
tree41e4f98991281921adf2ddb61e21c0d7456cd491 /ucb
parent95f7a01621dd5cd62190c334fcdf02e3941fdcab (diff)
rhbz#1163106: tdoc_ucp: fix life cycle of OfficeDocumentsCloseListener
The tdoc_ucp::OfficeDocumentsManager lives until the service manager is disposed on shutdown, but if the database stuff isn't disposed in due time then a document may call the notifyClosing() on the listener after the OfficeDocumentsManager dies; probably something is leaking the ODatabaseContext... Change-Id: I59662b910589d7270697452b2f4ca6c960d22f22
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/tdoc/tdoc_docmgr.cxx9
-rw-r--r--ucb/source/ucp/tdoc/tdoc_docmgr.hxx9
2 files changed, 12 insertions, 6 deletions
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
index f6da87a35421..79e4e2b015b4 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
@@ -74,6 +74,8 @@ void SAL_CALL OfficeDocumentsManager::OfficeDocumentsCloseListener::notifyClosin
const lang::EventObject& Source )
throw ( uno::RuntimeException, std::exception )
{
+ if (!m_pManager) return; // disposed?
+
document::DocumentEvent aDocEvent;
aDocEvent.Source = Source.Source;
aDocEvent.EventName = "OfficeDocumentsListener::notifyClosing";
@@ -124,6 +126,7 @@ OfficeDocumentsManager::~OfficeDocumentsManager()
// objects are actually released/destroyed upon shutdown is not defined. And when we arrive *here*,
// OOo *is* shutting down currently, since we're held by the TDOC provider, which is disposed
// upon shutdown.
+ m_xDocCloseListener->Dispose();
}
@@ -235,7 +238,7 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured(
"OnLoadFinished/OnCreate event: got no close broadcaster!" );
if ( xCloseBroadcaster.is() )
- xCloseBroadcaster->addCloseListener( m_xDocCloseListener );
+ xCloseBroadcaster->addCloseListener(m_xDocCloseListener.get());
// Propagate document closure.
OSL_ENSURE( m_pDocEventListener,
@@ -294,7 +297,7 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured(
"OnUnload event: got no XCloseBroadcaster from XModel" );
if ( xCloseBroadcaster.is() )
- xCloseBroadcaster->removeCloseListener( m_xDocCloseListener );
+ xCloseBroadcaster->removeCloseListener(m_xDocCloseListener.get());
m_aDocs.erase( it );
}
@@ -501,7 +504,7 @@ void OfficeDocumentsManager::buildDocumentsList()
"buildDocumentsList: got no close broadcaster!" );
if ( xCloseBroadcaster.is() )
- xCloseBroadcaster->addCloseListener( m_xDocCloseListener );
+ xCloseBroadcaster->addCloseListener(m_xDocCloseListener.get());
}
}
}
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
index 003e78476995..f71f0c78086e 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
@@ -22,6 +22,7 @@
#include <map>
+#include <rtl/ref.hxx>
#include "osl/mutex.hxx"
#include "cppuhelper/implbase1.hxx"
@@ -90,7 +91,7 @@ namespace tdoc_ucp {
{
public:
OfficeDocumentsCloseListener( OfficeDocumentsManager * pMgr )
- : m_pManager( pMgr ) {};
+ : m_pManager( pMgr ) {}
// util::XCloseListener
virtual void SAL_CALL queryClosing(
@@ -107,6 +108,9 @@ namespace tdoc_ucp {
virtual void SAL_CALL disposing(
const com::sun::star::lang::EventObject & Source )
throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
+
+ void Dispose() { m_pManager = 0; }
+
private:
OfficeDocumentsManager * m_pManager;
};
@@ -185,8 +189,7 @@ namespace tdoc_ucp {
com::sun::star::frame::XModuleManager2 > m_xModuleMgr;
DocumentList m_aDocs;
OfficeDocumentsEventListener * m_pDocEventListener;
- com::sun::star::uno::Reference<
- com::sun::star::util::XCloseListener > m_xDocCloseListener;
+ ::rtl::Reference<OfficeDocumentsCloseListener> m_xDocCloseListener;
};
} // namespace tdoc_ucp