sw/source/uibase/utlui/glbltree.cxx |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

New commits:
commit 30a59b8bebd6baab98c32e3fcfafe447f0c4ce9d
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Thu May 26 22:52:14 2022 -0800
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Jun 21 16:07:38 2022 +0200

    End listening and clear active shell when the dying shell view is the
    
    active shell view
    
    Corrects listening not being ended. This patch is based on the code
    in SwContentTree::Notify to end listening and clear the active shell
    when the dying shell view is the active shell view.
    
    Change-Id: Ic51e8b5355668e3bd133a8370eeb407694cc9e30
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135034
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 9dd3a493fd8d1b3e2aea1e4895ed07e202f3eff9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136235

diff --git a/sw/source/uibase/utlui/glbltree.cxx 
b/sw/source/uibase/utlui/glbltree.cxx
index 38abd661566c..4e64540c4a90 100644
--- a/sw/source/uibase/utlui/glbltree.cxx
+++ b/sw/source/uibase/utlui/glbltree.cxx
@@ -52,6 +52,9 @@
 #include <swabstdlg.hxx>
 #include <memory>
 
+#include <sfx2/event.hxx>
+#include <unotxvw.hxx>
+
 using namespace ::com::sun::star::uno;
 
 #define GLOBAL_UPDATE_TIMEOUT 2000
@@ -1118,9 +1121,21 @@ IMPL_LINK( SwGlobalTree, DialogClosedHdl, 
sfx2::FileDialogHelper*, _pFileDlg, vo
 
 void SwGlobalTree::Notify(SfxBroadcaster& rBC, SfxHint const& rHint)
 {
-    SfxListener::Notify(rBC, rHint);
-    if (rHint.GetId() == SfxHintId::SwNavigatorUpdateTracking)
-        UpdateTracking();
+    SfxViewEventHint const*const pVEHint(dynamic_cast<SfxViewEventHint 
const*>(&rHint));
+    SwXTextView* pDyingShell = nullptr;
+    if (m_pActiveShell && pVEHint && pVEHint->GetEventName() == "OnViewClosed")
+        pDyingShell = 
dynamic_cast<SwXTextView*>(pVEHint->GetController().get());
+    if (pDyingShell && pDyingShell->GetView() == &m_pActiveShell->GetView())
+    {
+        EndListening(*m_pActiveShell->GetView().GetDocShell());
+        m_pActiveShell = nullptr;
+    }
+    else
+    {
+        SfxListener::Notify(rBC, rHint);
+        if (rHint.GetId() == SfxHintId::SwNavigatorUpdateTracking)
+            UpdateTracking();
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to