[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl sfx2/source vcl/source

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Wed May 20 22:33:24 UTC 2020


 include/vcl/window.hxx         |    3 +++
 sfx2/source/sidebar/Deck.cxx   |    5 +++++
 vcl/source/app/svmain.cxx      |    3 +++
 vcl/source/window/floatwin.cxx |    2 ++
 vcl/source/window/window.cxx   |    8 +++++---
 5 files changed, 18 insertions(+), 3 deletions(-)

New commits:
commit 279eddb5062dbea9bb9461435ec0a56dbb25c131
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Mon Dec 9 18:49:37 2019 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Thu May 21 00:32:53 2020 +0200

    lok: evaluate assertion if LOK Windows container is empty
    
    It has defined a map container for every LOK windows assigned
    a notifier to the client side. However the map container has elements
    with VclPtr (reference counter) and it is a global data, so when global
    data are disposing, the VclPtr will destroy the Window when the VCL
    framework was destroyed that will lead to undefined behavior.
    
    So this commit adds an assert inside DeInitVCL to ensure, if
    someone forgot to Release the LOK Notifier.
    
    Change-Id: Ib7f20751af2931f7b0ba3e3d526e734ffc33f171
    Reviewed-on: https://gerrit.libreoffice.org/84792
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94504
    Tested-by: Henry Castro <hcastro at collabora.com>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index c0381b8c75c9..f090fef97203 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1205,6 +1205,9 @@ public:
     /// Find an existing Window based on the LOKWindowId.
     static VclPtr<vcl::Window>          FindLOKWindow(vcl::LOKWindowId nWindowId);
 
+    /// check if LOK Window container is empty
+    static bool                         IsLOKWindowsEmpty();
+
     /// Dumps itself and potentially its children to a property tree, to be written easily to JSON.
     virtual boost::property_tree::ptree DumpAsPropertyTree();
 
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index 3a0981719079..efc2658c453e 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -134,6 +134,11 @@ void Deck::dispose()
     mpScrollContainer.disposeAndClear();
     mpScrollClipWindow.disposeAndClear();
 
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        ReleaseLOKNotifier();
+    }
+
     vcl::Window::dispose();
 }
 
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index b0e3ce33b973..41a7126aa57f 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -404,6 +404,9 @@ VCLUnoWrapperDeleter::disposing(lang::EventObject const& /* rSource */)
 
 void DeInitVCL()
 {
+    // The LOK Windows map container should be empty
+    assert(vcl::Window::IsLOKWindowsEmpty());
+
     //rhbz#1444437, when using LibreOffice like a library you can't realistically
     //tear everything down and recreate them on the next call, there's too many
     //(c++) singletons that point to stuff that gets deleted during shutdown
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 40a0f1d3175d..223ed459e80c 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -203,6 +203,8 @@ FloatingWindow::~FloatingWindow()
 
 void FloatingWindow::dispose()
 {
+    ReleaseLOKNotifier();
+
     if (mpImplData)
     {
         if( mbPopupModeCanceled )
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index b7adc843e472..1670d728b51c 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3166,9 +3166,6 @@ namespace {
 
 LOKWindowsMap& GetLOKWindowsMap()
 {
-    // never use this in the desktop case
-    assert(comphelper::LibreOfficeKit::isActive());
-
     // Map to remember the LOKWindowId <-> Window binding.
     static LOKWindowsMap s_aLOKWindowsMap;
 
@@ -3210,6 +3207,11 @@ VclPtr<Window> Window::FindLOKWindow(vcl::LOKWindowId nWindowId)
     return VclPtr<Window>();
 }
 
+bool Window::IsLOKWindowsEmpty()
+{
+    return GetLOKWindowsMap().empty();
+}
+
 void Window::ReleaseLOKNotifier()
 {
     // unregister the LOK window binding


More information about the Libreoffice-commits mailing list