dbaccess/source/ui/browser/unodatbr.cxx               |    9 +++++----
 extensions/source/bibliography/framectr.cxx           |    5 +++++
 framework/source/fwe/helper/titlehelper.cxx           |    4 ++++
 framework/source/helper/persistentwindowstate.cxx     |    4 ++++
 framework/source/helper/tagwindowasmodified.cxx       |    3 +++
 framework/source/helper/titlebarupdate.cxx            |    4 ++++
 framework/source/uielement/resourcemenucontroller.cxx |    6 ++++++
 sdext/source/presenter/PresenterController.cxx        |   12 ++++++------
 svx/source/form/datanavi.cxx                          |    7 ++++---
 9 files changed, 41 insertions(+), 13 deletions(-)

New commits:
commit 697a112334f7bba510f4ca2fd3ac83670ecf06a0
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Tue Mar 30 15:00:49 2021 -0400
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Mon Apr 19 20:06:21 2021 +0200

    lok: remove frame action listener when disposing
    
    In order to prevent that the frame action listener
    holds the object reference count when removed,
    ensure they are removed when disposing the object.
    
    Change-Id: If83574e31230d9c683adaf36af36485650fd2c50
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113389
    Tested-by: Jenkins
    Reviewed-by: Henry Castro <hcas...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113455
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/dbaccess/source/ui/browser/unodatbr.cxx 
b/dbaccess/source/ui/browser/unodatbr.cxx
index c72d3a0b6e9b..f4cef5483f69 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -299,6 +299,11 @@ void SAL_CALL SbaTableQueryBrowser::disposing()
     // remove ourself as status listener
     implRemoveStatusListeners();
 
+    // check out from all the objects we are listening
+    // the frame
+    if (m_xCurrentFrameParent.is())
+        
m_xCurrentFrameParent->removeFrameActionListener(static_cast<css::frame::XFrameActionListener*>(this));
+
     // remove the container listener from the database context
     try
     {
@@ -310,10 +315,6 @@ void SAL_CALL SbaTableQueryBrowser::disposing()
         DBG_UNHANDLED_EXCEPTION("dbaccess");
     }
 
-    // check out from all the objects we are listening
-    // the frame
-    if (m_xCurrentFrameParent.is())
-        
m_xCurrentFrameParent->removeFrameActionListener(static_cast<css::frame::XFrameActionListener*>(this));
     SbaXDataBrowserController::disposing();
 }
 
diff --git a/extensions/source/bibliography/framectr.cxx 
b/extensions/source/bibliography/framectr.cxx
index 5bf197c3c74d..ce1e77594f42 100644
--- a/extensions/source/bibliography/framectr.cxx
+++ b/extensions/source/bibliography/framectr.cxx
@@ -224,6 +224,11 @@ void BibFrameController_Impl::dispose()
 {
     m_bDisposing = true;
     lang::EventObject aObject;
+    uno::Reference< XFrame > xFrame = getFrame();
+
+    if (xFrame.is())
+        xFrame->removeFrameActionListener( m_xImpl.get() );
+
     aObject.Source = static_cast<XController*>(this);
     m_xImpl->aLC.disposeAndClear(aObject);
     m_xDatMan.clear();
diff --git a/framework/source/fwe/helper/titlehelper.cxx 
b/framework/source/fwe/helper/titlehelper.cxx
index a50cc4b401af..2055d45919e6 100644
--- a/framework/source/fwe/helper/titlehelper.cxx
+++ b/framework/source/fwe/helper/titlehelper.cxx
@@ -245,6 +245,10 @@ void SAL_CALL TitleHelper::disposing(const 
css::lang::EventObject& aEvent)
     if ( ! xOwner.is ())
         return;
 
+    css::uno::Reference< css::frame::XFrame > xFrame(xOwner, 
css::uno::UNO_QUERY);
+    if (xFrame.is())
+        xFrame->removeFrameActionListener(this);
+
     if (xOwner != aEvent.Source)
         return;
 
diff --git a/framework/source/helper/persistentwindowstate.cxx 
b/framework/source/helper/persistentwindowstate.cxx
index aad137074d98..08e33ac527ef 100644
--- a/framework/source/helper/persistentwindowstate.cxx
+++ b/framework/source/helper/persistentwindowstate.cxx
@@ -136,6 +136,10 @@ void SAL_CALL PersistentWindowState::frameAction(const 
css::frame::FrameActionEv
 
 void SAL_CALL PersistentWindowState::disposing(const css::lang::EventObject&)
 {
+    css::uno::Reference< css::frame::XFrame > xFrame(m_xFrame.get(), 
css::uno::UNO_QUERY);
+    if (xFrame.is())
+        xFrame->removeFrameActionListener(this);
+
     // nothing todo here - because we hold the frame as weak reference only
 }
 
diff --git a/framework/source/helper/tagwindowasmodified.cxx 
b/framework/source/helper/tagwindowasmodified.cxx
index 3c40842dd6fa..7a72929763c5 100644
--- a/framework/source/helper/tagwindowasmodified.cxx
+++ b/framework/source/helper/tagwindowasmodified.cxx
@@ -128,6 +128,9 @@ void SAL_CALL TagWindowAsModified::disposing(const 
css::lang::EventObject& aEven
     SolarMutexGuard g;
 
     css::uno::Reference< css::frame::XFrame > xFrame(m_xFrame.get(), 
css::uno::UNO_QUERY);
+    if (xFrame.is())
+        xFrame->addFrameActionListener(this);
+
     if (
         (xFrame.is ()           ) &&
         (aEvent.Source == xFrame)
diff --git a/framework/source/helper/titlebarupdate.cxx 
b/framework/source/helper/titlebarupdate.cxx
index ff2d99c1e24a..601e0db44e0a 100644
--- a/framework/source/helper/titlebarupdate.cxx
+++ b/framework/source/helper/titlebarupdate.cxx
@@ -111,6 +111,10 @@ void SAL_CALL TitleBarUpdate::titleChanged(const 
css::frame::TitleChangedEvent&
 
 void SAL_CALL TitleBarUpdate::disposing(const css::lang::EventObject&)
 {
+    css::uno::Reference< css::frame::XFrame > xFrame(m_xFrame.get(), 
css::uno::UNO_QUERY);
+    if (xFrame.is())
+        xFrame->removeFrameActionListener(this);
+
     // nothing todo here - because we hold the frame as weak reference only
 }
 
diff --git a/framework/source/uielement/resourcemenucontroller.cxx 
b/framework/source/uielement/resourcemenucontroller.cxx
index 0594bfea8ddf..896c4d10cdc3 100644
--- a/framework/source/uielement/resourcemenucontroller.cxx
+++ b/framework/source/uielement/resourcemenucontroller.cxx
@@ -298,6 +298,9 @@ void ResourceMenuController::disposing( const 
css::lang::EventObject& rEvent )
     {
         if ( m_xMenuBarManager.is() )
         {
+            if (m_xFrame.is())
+                m_xFrame->removeFrameActionListener( m_xMenuBarManager.get() );
+
             m_xMenuBarManager->dispose();
             m_xMenuBarManager.clear();
         }
@@ -320,6 +323,9 @@ void ResourceMenuController::disposing()
     m_xMenuContainer.clear();
     if ( m_xMenuBarManager.is() )
     {
+        if (m_xFrame.is())
+            m_xFrame->removeFrameActionListener( m_xMenuBarManager.get() );
+
         m_xMenuBarManager->dispose();
         m_xMenuBarManager.clear();
     }
diff --git a/sdext/source/presenter/PresenterController.cxx 
b/sdext/source/presenter/PresenterController.cxx
index b26dfc2fb3af..601bbe1f9628 100644
--- a/sdext/source/presenter/PresenterController.cxx
+++ b/sdext/source/presenter/PresenterController.cxx
@@ -204,12 +204,6 @@ void PresenterController::disposing()
     if (mxConfigurationController.is())
         mxConfigurationController->removeConfigurationChangeListener(this);
 
-    Reference<XComponent> xWindowManagerComponent (
-        static_cast<XWeak*>(mpWindowManager.get()), UNO_QUERY);
-    mpWindowManager = nullptr;
-    if (xWindowManagerComponent.is())
-        xWindowManagerComponent->dispose();
-
     if (mxController.is())
     {
         Reference<frame::XFrame> xFrame (mxController->getFrame());
@@ -218,6 +212,12 @@ void PresenterController::disposing()
         mxController = nullptr;
     }
 
+    Reference<XComponent> xWindowManagerComponent (
+        static_cast<XWeak*>(mpWindowManager.get()), UNO_QUERY);
+    mpWindowManager = nullptr;
+    if (xWindowManagerComponent.is())
+        xWindowManagerComponent->dispose();
+
     mxComponentContext = nullptr;
     mxConfigurationController = nullptr;
     mxSlideShowController = nullptr;
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
index a409731f18c0..2a0d98744a93 100644
--- a/svx/source/form/datanavi.cxx
+++ b/svx/source/form/datanavi.cxx
@@ -1392,6 +1392,10 @@ namespace svxform
 
     void DataNavigatorWindow::dispose()
     {
+        Reference< XFrameActionListener > xListener(
+            static_cast< XFrameActionListener* >( m_xDataListener.get() ), 
UNO_QUERY );
+        m_xFrame->removeFrameActionListener( xListener );
+
         SvtViewOptions aViewOpt( EViewType::TabDialog, CFGNAME_DATANAVIGATOR );
         
aViewOpt.SetPageID(m_pTabCtrl->GetPageName(m_pTabCtrl->GetCurPageId()));
         aViewOpt.SetUserItem(CFGNAME_SHOWDETAILS, Any(m_bShowDetails));
@@ -1405,9 +1409,6 @@ namespace svxform
             m_aPageList[i].disposeAndClear();
         m_aPageList.clear();
 
-        Reference< XFrameActionListener > xListener(
-            static_cast< XFrameActionListener* >( m_xDataListener.get() ), 
UNO_QUERY );
-        m_xFrame->removeFrameActionListener( xListener );
         RemoveBroadcaster();
         m_xDataListener.clear();
         disposeBuilder();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to