[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - ucb/source

Michael Stahl mstahl at redhat.com
Fri Jan 16 01:10:56 PST 2015


 ucb/source/ucp/tdoc/tdoc_docmgr.cxx |    9 ++++++---
 ucb/source/ucp/tdoc/tdoc_docmgr.hxx |    9 ++++++---
 2 files changed, 12 insertions(+), 6 deletions(-)

New commits:
commit 8f00af819f024212c9362aa3c98000f5dff549d3
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Jan 15 21:47:44 2015 +0100

    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
    (cherry picked from commit 0ffa3abc7d6c0437ece30cfb1430d28ffcc9f5c1)
    Reviewed-on: https://gerrit.libreoffice.org/13944
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
index f6da87a3..79e4e2b 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 003e784..f71f0c7 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


More information about the Libreoffice-commits mailing list