From fec15bc826459c02459249e2f1d053db87a3670b Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Fri, 24 May 2019 15:10:03 +0200 Subject: Enable the option to remove previous user PrefService We need this change so we can replace the previous user PrefService with a new one when changing the data path in QWebEngineProfile. If we don't have this change, the code will assert. This is required to properly fix QTBUG-75740. Change-Id: I956f0b0549caf258cc49ac0818f6eca0ddcbafd7 Reviewed-by: Allan Sandfeld Jensen --- chromium/components/user_prefs/user_prefs.cc | 9 +++++++++ chromium/components/user_prefs/user_prefs.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/chromium/components/user_prefs/user_prefs.cc b/chromium/components/user_prefs/user_prefs.cc index a752c8f8acc..dff5f2a258d 100644 --- a/chromium/components/user_prefs/user_prefs.cc +++ b/chromium/components/user_prefs/user_prefs.cc @@ -38,6 +38,15 @@ void UserPrefs::Set(base::SupportsUserData* context, PrefService* prefs) { context->SetUserData(UserDataKey(), base::WrapUnique(new UserPrefs(prefs))); } +// static +// TODO: Remove in Qt6 when contexts are only set once +void UserPrefs::Remove(base::SupportsUserData* context) { + DCHECK(context); + DCHECK(context->GetUserData(UserDataKey())); + context->RemoveUserData(UserDataKey()); +} + + UserPrefs::UserPrefs(PrefService* prefs) : prefs_(prefs) { } diff --git a/chromium/components/user_prefs/user_prefs.h b/chromium/components/user_prefs/user_prefs.h index 392e5dc7f23..3a86997cf23 100644 --- a/chromium/components/user_prefs/user_prefs.h +++ b/chromium/components/user_prefs/user_prefs.h @@ -29,6 +29,10 @@ class USER_PREFS_EXPORT UserPrefs : public base::SupportsUserData::Data { // only once per context. static void Set(base::SupportsUserData* context, PrefService* prefs); + // Remove existing |prefs| on a |context|. + // TODO: Remove in Qt6 when contexts are only set once + static void Remove(base::SupportsUserData* context); + private: explicit UserPrefs(PrefService* prefs); -- cgit v1.2.1