diff options
Diffstat (limited to 'core/fxcrt/autorestorer.h')
-rw-r--r-- | core/fxcrt/autorestorer.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/fxcrt/autorestorer.h b/core/fxcrt/autorestorer.h index 745a56fff2..cafa075137 100644 --- a/core/fxcrt/autorestorer.h +++ b/core/fxcrt/autorestorer.h @@ -12,10 +12,14 @@ class AutoRestorer { public: explicit AutoRestorer(T* location) : m_Location(location), m_OldValue(*location) {} - ~AutoRestorer() { *m_Location = m_OldValue; } + ~AutoRestorer() { + if (m_Location) + *m_Location = m_OldValue; + } + void AbandonRestoration() { m_Location = nullptr; } private: - T* const m_Location; + T* m_Location; const T m_OldValue; }; |