diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-08-28 22:39:25 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-08-29 09:49:56 +0200 |
commit | 9cd44d9426b95f9a449fb3ad56dac758747a0802 (patch) | |
tree | 432f8cabb4a5bd4865d6e7beea4cefb12bc76e02 | |
parent | 7b2c691d21bf0ac7bb47de41b79ef5dd968dbf1b (diff) |
sd: delete the global CacheConfiguration timer on shutdown
Crashes in SchedulerMutex::acquire if destroyed from __run_exit_handlers
Change-Id: Ie8bbb399183d118d92c94a40f55cc9c650baf742
Reviewed-on: https://gerrit.libreoffice.org/41629
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx | 18 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/cache/SlsCacheConfiguration.hxx | 4 | ||||
-rw-r--r-- | 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> CacheConfiguration::mpWeakInstance; -Timer CacheConfiguration::maReleaseTimer; std::shared_ptr<CacheConfiguration> CacheConfiguration::Instance() { @@ -58,11 +57,11 @@ std::shared_ptr<CacheConfiguration> 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<CacheConfiguration> 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<CacheConfiguration> mpWeakInstance; - static Timer maReleaseTimer; + Timer m_ReleaseTimer; css::uno::Reference<css::container::XNameAccess> 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 <comphelper/processfactory.hxx> #include <comphelper/unique_disposing_ptr.hxx> @@ -194,6 +196,8 @@ SdGlobalResourceContainer::~SdGlobalResourceContainer() if (xComponent.is()) xComponent->dispose(); } + + sd::slidesorter::cache::CacheConfiguration::Shutdown(); } } // end of namespace sd |