summaryrefslogtreecommitdiff
path: root/core/fxcrt/autorestorer.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-27 21:14:22 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-27 21:14:22 +0000
commita2c2a9d2a1e718e08bb90f92a2f24f4cb990189f (patch)
tree79b96a806474543b292a3b6b3df9d8fcc74b8a50 /core/fxcrt/autorestorer.h
parent3ab8fa91422e8ce6874f9a89a61cb043858ad8b5 (diff)
downloadpdfium-a2c2a9d2a1e718e08bb90f92a2f24f4cb990189f.tar.xz
Add fxcrt::AutoRestorer<T>::AbandonRestoration().chromium/3475
Kinda like reaching a commit point, makes going forward more useful. Change-Id: I7695b6e627d4cd8ed2bccb667d0cabd7f42c7b1c Reviewed-on: https://pdfium-review.googlesource.com/35970 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt/autorestorer.h')
-rw-r--r--core/fxcrt/autorestorer.h8
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;
};