1
Description: This bug is due to the fact, applications are restarted before extension
4
To reproduce, choose any preference and set the values like:
6
pref("prefkey",systemvalue);
8
pref("prefkey", extensiondefault);
10
user_pref("prefkey", systemvalue);
12
Next, trigger application behaviour similar to upgrade by removing compreg.dat
13
from profile and start the application.
16
User sees extensiondefault after upgrade, because the user_pref has been
17
eliminated ... which is definitly not what the user expects because he explicitly
18
had *systemvalue* set before the upgrade.
21
The bug happens because restart is performed *before* extension defaults have been
22
loaded and the prefapi.cpp always eliminate user preference if the user preference
23
is equal to the actual default (which happens to be extensiondefault normally - so
24
no reset, but is systemvalue during restart).
27
1. savePrefs should not try to be smart ... this patch removes the heuristic that guesses
28
whether a setting can be eliminated or not; it should be sufficient to only eliminate
31
2. This patch prevents hashPrefs from eliminating the user pref in case we are in
32
*startup* ... unfortunately no such state info exists, which lets us guess that
33
we are in startup for the previously not dealt case: !set_default &&
34
!pref_ValueChanged(pref->defaultPref, value, type) && !PREF_HAS_USER_VALUE(pref).
36
If is the case we explicitly remember that this setting is a user-pref ...
37
even though it might be temporarily equal to the default pref.
38
Author: Alexander Sack <asac@ubuntu.com>
39
Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=467766
40
Bug-Ubuntu: https://launchpad.net/bugs/548866
41
Forwarded: https://bugzilla.mozilla.org/attachment.cgi?id=351173
44
modules/libpref/src/prefapi.cpp | 16 ++++++++++++----
45
1 file changed, 12 insertions(+), 4 deletions(-)
47
--- a/modules/libpref/src/prefapi.cpp
48
+++ b/modules/libpref/src/prefapi.cpp
49
@@ -328,10 +328,7 @@ pref_savePref(PLDHashTable *table, PLDHa
50
// where we're getting our pref from
51
PrefValue* sourcePref;
53
- if (PREF_HAS_USER_VALUE(pref) &&
54
- pref_ValueChanged(pref->defaultPref,
56
- (PrefType) PREF_TYPE(pref))) {
57
+ if (PREF_HAS_USER_VALUE(pref)) {
58
sourcePref = &pref->userPref;
60
if (argData->saveTypes == SAVE_ALL_AND_DEFAULTS) {
61
@@ -748,6 +745,17 @@ nsresult pref_HashPref(const char *key,
62
pref->flags &= ~PREF_USERSET;
63
if (!PREF_IS_LOCKED(pref))
64
valueChanged = PR_TRUE;
66
+ // this is tricky: we have !set_default ...
67
+ // thus we are setting a user pref; however the user
68
+ // pref set is same as *current default*; this normally
69
+ // means to un-set ... however since we have
70
+ // !PREF_HAS_USER_VALUE(pref) this can only be during
72
+ pref_SetValue(&pref->userPref, value, type);
73
+ pref->flags |= PREF_USERSET;
74
+ if (!PREF_IS_LOCKED(pref))
75
+ valueChanged = PR_TRUE;
78
else if ( !PREF_HAS_USER_VALUE(pref) ||