diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-29 20:41:48 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 10:10:22 +0200 |
commit | 231e1e416c039d1f9724962a89cf0573a3db48a2 (patch) | |
tree | 7fea67891c544b4cc69679e94e47e1950c10bb52 /basic/source/sbx | |
parent | 75f398b22ae14dcf442abf6b1c92a50509565ae5 (diff) |
fix shutdown crash in basic
another change I am working on slightly tweaks the shutdown ordering
and exposes this problem where two classes both think they own
the same object.
Change-Id: I7477cf7eda5b5729ee3861cb4a1be43bb34d9ea6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99724
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic/source/sbx')
-rw-r--r-- | basic/source/sbx/sbxbase.cxx | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx index c80b681c644d..f62949ada7ec 100644 --- a/basic/source/sbx/sbxbase.cxx +++ b/basic/source/sbx/sbxbase.cxx @@ -48,7 +48,9 @@ SbxAppData::~SbxAppData() pBasicFormater.reset(); // basic manager repository must be destroyed before factories mrImplRepository.clear(); - m_Factories.clear(); + // we need to move stuff out otherwise the destruction of the factories + // calls back into SbxBase::RemoveFactory and sees partially destructed data + std::move(m_Factories); } SbxBase::SbxBase() @@ -121,15 +123,12 @@ void SbxBase::AddFactory( SbxFactory* pFac ) void SbxBase::RemoveFactory( SbxFactory const * pFac ) { + if (!IsSbxData_Impl()) + return; SbxAppData& r = GetSbxData_Impl(); - auto it = std::find_if(r.m_Factories.begin(), r.m_Factories.end(), - [&pFac](const std::unique_ptr<SbxFactory>& rxFactory) { return rxFactory.get() == pFac; }); + auto it = std::find(r.m_Factories.begin(), r.m_Factories.end(), pFac); if (it != r.m_Factories.end()) - { - std::unique_ptr<SbxFactory> tmp(std::move(*it)); r.m_Factories.erase( it ); - (void)tmp.release(); - } } |