Index: chrome/browser/prefs/pref_member.cc |
diff --git a/chrome/browser/prefs/pref_member.cc b/chrome/browser/prefs/pref_member.cc |
index cc143846cf710e4604c324148a1a737e62a5eac6..0b3848602783e3681968a2cd3ed32deea81333fc 100644 |
--- a/chrome/browser/prefs/pref_member.cc |
+++ b/chrome/browser/prefs/pref_member.cc |
@@ -18,7 +18,7 @@ PrefMemberBase::PrefMemberBase() |
} |
PrefMemberBase::~PrefMemberBase() { |
- if (!pref_name_.empty()) |
+ if (prefs_ && !pref_name_.empty()) |
prefs_->RemovePrefObserver(pref_name_.c_str(), this); |
} |
@@ -37,6 +37,13 @@ void PrefMemberBase::Init(const char* pref_name, PrefService* prefs, |
prefs_->AddPrefObserver(pref_name, this); |
} |
+void PrefMemberBase::Destroy() { |
+ if (prefs_) { |
+ prefs_->RemovePrefObserver(pref_name_.c_str(), this); |
+ prefs_ = NULL; |
+ } |
Dan Beam
2016/06/17 21:56:15
out of curiosity, could pref_name_.clear() be call
battre
2016/06/20 07:53:46
I did not find anything subtle that would break.
Dan Beam
2016/06/21 22:50:41
I think making Destroy() private and encouraging f
|
+} |
+ |
bool PrefMemberBase::IsManaged() const { |
DCHECK(!pref_name_.empty()); |
const PrefService::Preference* pref = |