Kaydet (Commit) 0ffa3abc authored tarafından Michael Stahl's avatar Michael Stahl

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
üst 95f7a016
...@@ -74,6 +74,8 @@ void SAL_CALL OfficeDocumentsManager::OfficeDocumentsCloseListener::notifyClosin ...@@ -74,6 +74,8 @@ void SAL_CALL OfficeDocumentsManager::OfficeDocumentsCloseListener::notifyClosin
const lang::EventObject& Source ) const lang::EventObject& Source )
throw ( uno::RuntimeException, std::exception ) throw ( uno::RuntimeException, std::exception )
{ {
if (!m_pManager) return; // disposed?
document::DocumentEvent aDocEvent; document::DocumentEvent aDocEvent;
aDocEvent.Source = Source.Source; aDocEvent.Source = Source.Source;
aDocEvent.EventName = "OfficeDocumentsListener::notifyClosing"; aDocEvent.EventName = "OfficeDocumentsListener::notifyClosing";
...@@ -124,6 +126,7 @@ OfficeDocumentsManager::~OfficeDocumentsManager() ...@@ -124,6 +126,7 @@ OfficeDocumentsManager::~OfficeDocumentsManager()
// objects are actually released/destroyed upon shutdown is not defined. And when we arrive *here*, // 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 // OOo *is* shutting down currently, since we're held by the TDOC provider, which is disposed
// upon shutdown. // upon shutdown.
m_xDocCloseListener->Dispose();
} }
...@@ -235,7 +238,7 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured( ...@@ -235,7 +238,7 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured(
"OnLoadFinished/OnCreate event: got no close broadcaster!" ); "OnLoadFinished/OnCreate event: got no close broadcaster!" );
if ( xCloseBroadcaster.is() ) if ( xCloseBroadcaster.is() )
xCloseBroadcaster->addCloseListener( m_xDocCloseListener ); xCloseBroadcaster->addCloseListener(m_xDocCloseListener.get());
// Propagate document closure. // Propagate document closure.
OSL_ENSURE( m_pDocEventListener, OSL_ENSURE( m_pDocEventListener,
...@@ -294,7 +297,7 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured( ...@@ -294,7 +297,7 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured(
"OnUnload event: got no XCloseBroadcaster from XModel" ); "OnUnload event: got no XCloseBroadcaster from XModel" );
if ( xCloseBroadcaster.is() ) if ( xCloseBroadcaster.is() )
xCloseBroadcaster->removeCloseListener( m_xDocCloseListener ); xCloseBroadcaster->removeCloseListener(m_xDocCloseListener.get());
m_aDocs.erase( it ); m_aDocs.erase( it );
} }
...@@ -501,7 +504,7 @@ void OfficeDocumentsManager::buildDocumentsList() ...@@ -501,7 +504,7 @@ void OfficeDocumentsManager::buildDocumentsList()
"buildDocumentsList: got no close broadcaster!" ); "buildDocumentsList: got no close broadcaster!" );
if ( xCloseBroadcaster.is() ) if ( xCloseBroadcaster.is() )
xCloseBroadcaster->addCloseListener( m_xDocCloseListener ); xCloseBroadcaster->addCloseListener(m_xDocCloseListener.get());
} }
} }
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <map> #include <map>
#include <rtl/ref.hxx>
#include "osl/mutex.hxx" #include "osl/mutex.hxx"
#include "cppuhelper/implbase1.hxx" #include "cppuhelper/implbase1.hxx"
...@@ -90,7 +91,7 @@ namespace tdoc_ucp { ...@@ -90,7 +91,7 @@ namespace tdoc_ucp {
{ {
public: public:
OfficeDocumentsCloseListener( OfficeDocumentsManager * pMgr ) OfficeDocumentsCloseListener( OfficeDocumentsManager * pMgr )
: m_pManager( pMgr ) {}; : m_pManager( pMgr ) {}
// util::XCloseListener // util::XCloseListener
virtual void SAL_CALL queryClosing( virtual void SAL_CALL queryClosing(
...@@ -107,6 +108,9 @@ namespace tdoc_ucp { ...@@ -107,6 +108,9 @@ namespace tdoc_ucp {
virtual void SAL_CALL disposing( virtual void SAL_CALL disposing(
const com::sun::star::lang::EventObject & Source ) const com::sun::star::lang::EventObject & Source )
throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
void Dispose() { m_pManager = 0; }
private: private:
OfficeDocumentsManager * m_pManager; OfficeDocumentsManager * m_pManager;
}; };
...@@ -185,8 +189,7 @@ namespace tdoc_ucp { ...@@ -185,8 +189,7 @@ namespace tdoc_ucp {
com::sun::star::frame::XModuleManager2 > m_xModuleMgr; com::sun::star::frame::XModuleManager2 > m_xModuleMgr;
DocumentList m_aDocs; DocumentList m_aDocs;
OfficeDocumentsEventListener * m_pDocEventListener; OfficeDocumentsEventListener * m_pDocEventListener;
com::sun::star::uno::Reference< ::rtl::Reference<OfficeDocumentsCloseListener> m_xDocCloseListener;
com::sun::star::util::XCloseListener > m_xDocCloseListener;
}; };
} // namespace tdoc_ucp } // namespace tdoc_ucp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment