diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fxcrt/include/cfx_observable.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/core/fxcrt/include/cfx_observable.h b/core/fxcrt/include/cfx_observable.h index b669e0d3d5..99a9951284 100644 --- a/core/fxcrt/include/cfx_observable.h +++ b/core/fxcrt/include/cfx_observable.h @@ -45,10 +45,7 @@ class CFX_Observable { CFX_Observable() {} CFX_Observable(const CFX_Observable& that) = delete; - ~CFX_Observable() { - for (auto* pObserver : m_Observers) - pObserver->OnDestroy(); - } + ~CFX_Observable() { NotifyObservers(); } void AddObserver(Observer* pObserver) { ASSERT(!pdfium::ContainsKey(m_Observers, pObserver)); m_Observers.insert(pObserver); @@ -57,6 +54,11 @@ class CFX_Observable { ASSERT(pdfium::ContainsKey(m_Observers, pObserver)); m_Observers.erase(pObserver); } + void NotifyObservers() { + for (auto* pObserver : m_Observers) + pObserver->OnDestroy(); + m_Observers.clear(); + } CFX_Observable& operator=(const CFX_Observable& that) = delete; private: |