mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 1372988 part A - Warn when user prefs are set after the profile is dead, because the prefs won't get saved anyway. r=milan
MozReview-Commit-ID: IfwL5yYtLcF --HG-- extra : rebase_source : f03a79b5f7c3b8eb802bfd2db9991e5ed6c74a8f
This commit is contained in:
parent
5cf8c34a94
commit
bfee2567d6
@ -102,6 +102,9 @@ Preferences::DirtyCallback()
|
|||||||
}
|
}
|
||||||
if (gHashTable && sPreferences && !sPreferences->mDirty) {
|
if (gHashTable && sPreferences && !sPreferences->mDirty) {
|
||||||
sPreferences->mDirty = true;
|
sPreferences->mDirty = true;
|
||||||
|
|
||||||
|
NS_WARNING_ASSERTION(!sPreferences->mProfileShutdown,
|
||||||
|
"Setting user pref after profile shutdown.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,7 +665,6 @@ Preferences::Shutdown()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Preferences::Preferences()
|
Preferences::Preferences()
|
||||||
: mDirty(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -796,11 +798,19 @@ Preferences::Observe(nsISupports *aSubject, const char *aTopic,
|
|||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
|
if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
|
||||||
rv = SavePrefFile(nullptr);
|
// Normally prefs aren't written after this point, and so we kick off
|
||||||
} else if (!nsCRT::strcmp(aTopic, "profile-before-change-telemetry")) {
|
// an asynchronous pref save so that I/O can be done in parallel with
|
||||||
|
// other shutdown.
|
||||||
if (AllowOffMainThreadSave()) {
|
if (AllowOffMainThreadSave()) {
|
||||||
PreferencesWriter::Flush();
|
SavePrefFile(nullptr);
|
||||||
}
|
}
|
||||||
|
} else if (!nsCRT::strcmp(aTopic, "profile-before-change-telemetry")) {
|
||||||
|
// It's possible that a profile-before-change observer after ours
|
||||||
|
// set a pref. A blocking save here re-saves if necessary and also waits
|
||||||
|
// for any pending saves to complete.
|
||||||
|
SavePrefFileBlocking();
|
||||||
|
MOZ_ASSERT(!mDirty, "Preferences should not be dirty");
|
||||||
|
mProfileShutdown = true;
|
||||||
} else if (!strcmp(aTopic, "load-extension-defaults")) {
|
} else if (!strcmp(aTopic, "load-extension-defaults")) {
|
||||||
pref_LoadPrefsInDirList(NS_EXT_PREFS_DEFAULTS_DIR_LIST);
|
pref_LoadPrefsInDirList(NS_EXT_PREFS_DEFAULTS_DIR_LIST);
|
||||||
} else if (!nsCRT::strcmp(aTopic, "reload-default-prefs")) {
|
} else if (!nsCRT::strcmp(aTopic, "reload-default-prefs")) {
|
||||||
@ -1154,6 +1164,13 @@ Preferences::SavePrefFileInternal(nsIFile *aFile, SaveMethod aSaveMethod)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for profile shutdown after mDirty because the runnables from
|
||||||
|
// DirtyCallback can still be pending
|
||||||
|
if (mProfileShutdown) {
|
||||||
|
NS_WARNING("Cannot save pref file after profile shutdown.");
|
||||||
|
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
|
||||||
|
}
|
||||||
|
|
||||||
// It's possible that we never got a prefs file.
|
// It's possible that we never got a prefs file.
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
if (mCurrentFile) {
|
if (mCurrentFile) {
|
||||||
|
@ -485,7 +485,8 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsIFile> mCurrentFile;
|
nsCOMPtr<nsIFile> mCurrentFile;
|
||||||
bool mDirty;
|
bool mDirty = false;
|
||||||
|
bool mProfileShutdown = false;
|
||||||
|
|
||||||
static Preferences* sPreferences;
|
static Preferences* sPreferences;
|
||||||
static nsIPrefBranch* sRootBranch;
|
static nsIPrefBranch* sRootBranch;
|
||||||
|
Loading…
Reference in New Issue
Block a user