diff options
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/chartlis.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/docshell/externalrefmgr.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 3 |
3 files changed, 17 insertions, 3 deletions
diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx index 18b69b12d92b..3566e357f67b 100644 --- a/sc/source/core/tool/chartlis.cxx +++ b/sc/source/core/tool/chartlis.cxx @@ -50,18 +50,18 @@ public: // ScChartListener ScChartListener::ExternalRefListener::ExternalRefListener(ScChartListener& rParent, ScDocument& rDoc) : - mrParent(rParent), mrDoc(rDoc) + mrParent(rParent), m_pDoc(&rDoc) { } ScChartListener::ExternalRefListener::~ExternalRefListener() { - if (mrDoc.IsInDtorClear()) + if (!m_pDoc || m_pDoc->IsInDtorClear()) // The document is being destroyed. Do nothing. return; // Make sure to remove all pointers to this object. - mrDoc.GetExternalRefManager()->removeLinkListener(this); + m_pDoc->GetExternalRefManager()->removeLinkListener(this); } void ScChartListener::ExternalRefListener::notify(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType) @@ -79,6 +79,9 @@ void ScChartListener::ExternalRefListener::notify(sal_uInt16 nFileId, ScExternal case ScExternalRefManager::LINK_BROKEN: removeFileId(nFileId); break; + case ScExternalRefManager::OH_NO_WE_ARE_GOING_TO_DIE: + m_pDoc = nullptr; + break; } } diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx index 3d1845cbeacb..f03815fdaa16 100644 --- a/sc/source/ui/docshell/externalrefmgr.cxx +++ b/sc/source/ui/docshell/externalrefmgr.cxx @@ -3106,6 +3106,14 @@ void ScExternalRefManager::setFilterData(sal_uInt16 nFileId, const OUString& rFi void ScExternalRefManager::clear() { + for (auto& rEntry : maLinkListeners) + { + for (auto& it : rEntry.second) + { + it->notify(0, OH_NO_WE_ARE_GOING_TO_DIE); + } + } + for (auto& rEntry : maDocShells) rEntry.second.maShell->DoClose(); diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 447e3b2ae6d0..adc244bacc78 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2916,6 +2916,9 @@ void ScChart2DataSequence::ExternalRefListener::notify(sal_uInt16 nFileId, ScExt case ScExternalRefManager::LINK_BROKEN: maFileIds.erase(nFileId); break; + case ScExternalRefManager::OH_NO_WE_ARE_GOING_TO_DIE: + mpDoc = nullptr; + break; } } |