From 9cd44d9426b95f9a449fb3ad56dac758747a0802 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 28 Aug 2017 22:39:25 +0200 Subject: sd: delete the global CacheConfiguration timer on shutdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Crashes in SchedulerMutex::acquire if destroyed from __run_exit_handlers Change-Id: Ie8bbb399183d118d92c94a40f55cc9c650baf742 Reviewed-on: https://gerrit.libreoffice.org/41629 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- .../ui/slidesorter/cache/SlsCacheConfiguration.cxx | 18 +++++++++++++----- .../ui/slidesorter/cache/SlsCacheConfiguration.hxx | 4 +++- sd/source/ui/tools/SdGlobalResourceContainer.cxx | 4 ++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx index 8bb01e4b7bbb..8d2be1ddcafb 100644 --- a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx +++ b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx @@ -41,7 +41,6 @@ namespace } std::weak_ptr CacheConfiguration::mpWeakInstance; -Timer CacheConfiguration::maReleaseTimer; std::shared_ptr CacheConfiguration::Instance() { @@ -58,11 +57,11 @@ std::shared_ptr CacheConfiguration::Instance() rInstancePtr.reset(new CacheConfiguration()); mpWeakInstance = rInstancePtr; // Prepare to release this instance in the near future. - maReleaseTimer.SetInvokeHandler( + rInstancePtr->m_ReleaseTimer.SetInvokeHandler( LINK(rInstancePtr.get(),CacheConfiguration,TimerCallback)); - maReleaseTimer.SetTimeout(5000 /* 5s */); - maReleaseTimer.SetDebugName("sd::CacheConfiguration maReleaseTimer"); - maReleaseTimer.Start(); + rInstancePtr->m_ReleaseTimer.SetTimeout(5000 /* 5s */); + rInstancePtr->m_ReleaseTimer.SetDebugName("sd::CacheConfiguration maReleaseTimer"); + rInstancePtr->m_ReleaseTimer.Start(); } } return rInstancePtr; @@ -131,6 +130,15 @@ IMPL_STATIC_LINK_NOARG(CacheConfiguration, TimerCallback, Timer *, void) CacheConfigSharedPtr &rInstancePtr = theInstance::get(); // Release our reference to the instance. rInstancePtr.reset(); + // note: if there are no other references to the instance, m_ReleaseTimer + // will be deleted now +} + +void CacheConfiguration::Shutdown() +{ + CacheConfigSharedPtr &rInstancePtr = theInstance::get(); + rInstancePtr.reset(); + assert(mpWeakInstance.expired()); // ensure m_ReleaseTimer is destroyed } } } } // end of namespace ::sd::slidesorter::cache diff --git a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.hxx b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.hxx index 74a8097f02db..5d2a22cc1c51 100644 --- a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.hxx +++ b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.hxx @@ -39,6 +39,8 @@ public: */ static std::shared_ptr Instance(); + static void Shutdown(); + /** Look up the specified value in MultiPaneGUI/SlideSorter/PreviewCache. When the specified value does not exist then an empty Any is returned. @@ -50,7 +52,7 @@ private: this weak pointer to avoid creating a new instance. */ static std::weak_ptr mpWeakInstance; - static Timer maReleaseTimer; + Timer m_ReleaseTimer; css::uno::Reference mxCacheNode; CacheConfiguration(); diff --git a/sd/source/ui/tools/SdGlobalResourceContainer.cxx b/sd/source/ui/tools/SdGlobalResourceContainer.cxx index c1dc47bc917e..bcafcb52d701 100644 --- a/sd/source/ui/tools/SdGlobalResourceContainer.cxx +++ b/sd/source/ui/tools/SdGlobalResourceContainer.cxx @@ -19,6 +19,8 @@ #include "tools/SdGlobalResourceContainer.hxx" +#include "../cache/SlsCacheConfiguration.hxx" + #include #include @@ -194,6 +196,8 @@ SdGlobalResourceContainer::~SdGlobalResourceContainer() if (xComponent.is()) xComponent->dispose(); } + + sd::slidesorter::cache::CacheConfiguration::Shutdown(); } } // end of namespace sd -- cgit