Chromium Code Reviews| Index: src/assert-scope.cc |
| diff --git a/src/assert-scope.cc b/src/assert-scope.cc |
| index 38527099667acc827a55f164af22ffda4d685307..a14b07f42b9e7ccd763f27bf67d552ee6a8b73c5 100644 |
| --- a/src/assert-scope.cc |
| +++ b/src/assert-scope.cc |
| @@ -83,7 +83,7 @@ PerThreadAssertScope<kType, kAllow>::PerThreadAssertScope() |
| template <PerThreadAssertType kType, bool kAllow> |
| PerThreadAssertScope<kType, kAllow>::~PerThreadAssertScope() { |
| - DCHECK_NOT_NULL(data_); |
| + if (data_ == nullptr) return; |
| data_->Set(kType, old_state_); |
| if (data_->DecrementLevel()) { |
| PerThreadAssertData::SetCurrent(NULL); |
| @@ -91,6 +91,16 @@ PerThreadAssertScope<kType, kAllow>::~PerThreadAssertScope() { |
| } |
|
rmcilroy
2017/01/17 10:41:31
Could you just call Release here rather than dupli
Leszek Swirski
2017/01/17 12:11:49
Not directly, because of the DCHECK, but extracted
Leszek Swirski
2017/01/17 12:17:18
Ignore me, I'm an idiot. Done.
|
| } |
| +template <PerThreadAssertType kType, bool kAllow> |
| +void PerThreadAssertScope<kType, kAllow>::Release() { |
| + DCHECK_NOT_NULL(data_); |
| + data_->Set(kType, old_state_); |
| + if (data_->DecrementLevel()) { |
| + PerThreadAssertData::SetCurrent(NULL); |
| + delete data_; |
| + } |
| + data_ = nullptr; |
| +} |
| // static |
| template <PerThreadAssertType kType, bool kAllow> |