Fx60: Update pref handling
- getStringPref/setStringPref are now used for strings instead of getComplexValue/setComplexValue - Remove nsIPrefBranch2 reference - If there was a pref failure during initialization, nothing was logged to the terminal
This commit is contained in:
parent
d4b10f1c1e
commit
331522b106
1 changed files with 33 additions and 9 deletions
|
@ -98,13 +98,22 @@ Zotero.Prefs = new function(){
|
|||
case branch.PREF_BOOL:
|
||||
return branch.getBoolPref(pref);
|
||||
case branch.PREF_STRING:
|
||||
return '' + branch.getComplexValue(pref, Components.interfaces.nsISupportsString);
|
||||
// Pre-Fx59
|
||||
if (!branch.getStringPref) {
|
||||
return '' + branch.getComplexValue(pref, Components.interfaces.nsISupportsString);
|
||||
}
|
||||
return branch.getStringPref(pref);
|
||||
case branch.PREF_INT:
|
||||
return branch.getIntPref(pref);
|
||||
}
|
||||
}
|
||||
catch (e){
|
||||
throw new Error("Invalid preference '" + pref + "'");
|
||||
catch (e) {
|
||||
// If debug system isn't yet initialized, log proper error
|
||||
if (Zotero.Debug.enabled === undefined) {
|
||||
dump(e + "\n\n");
|
||||
}
|
||||
Zotero.logError(e);
|
||||
throw new Error(`Error getting preference '${pref}'`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,10 +134,14 @@ Zotero.Prefs = new function(){
|
|||
case branch.PREF_BOOL:
|
||||
return branch.setBoolPref(pref, value);
|
||||
case branch.PREF_STRING:
|
||||
let str = Cc["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
str.data = value;
|
||||
return branch.setComplexValue(pref, Ci.nsISupportsString, str);
|
||||
// Pre-Fx59
|
||||
if (!branch.setStringPref) {
|
||||
let str = Cc["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
str.data = value;
|
||||
return branch.setComplexValue(pref, Ci.nsISupportsString, str);
|
||||
}
|
||||
return branch.setStringPref(pref, value);
|
||||
case branch.PREF_INT:
|
||||
return branch.setIntPref(pref, value);
|
||||
|
||||
|
@ -140,7 +153,14 @@ Zotero.Prefs = new function(){
|
|||
}
|
||||
if (typeof value == 'string') {
|
||||
Zotero.debug("Creating string pref '" + pref + "'");
|
||||
return branch.setCharPref(pref, value);
|
||||
// Pre-Fx59
|
||||
if (!branch.setStringPref) {
|
||||
let str = Cc["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
str.data = value;
|
||||
return branch.setComplexValue(pref, Ci.nsISupportsString, str);
|
||||
}
|
||||
return branch.setStringPref(pref, value);
|
||||
}
|
||||
if (parseInt(value) == value) {
|
||||
Zotero.debug("Creating integer pref '" + pref + "'");
|
||||
|
@ -150,8 +170,12 @@ Zotero.Prefs = new function(){
|
|||
}
|
||||
}
|
||||
catch (e) {
|
||||
// If debug system isn't yet initialized, log proper error
|
||||
if (Zotero.Debug.enabled === undefined) {
|
||||
dump(e + "\n\n");
|
||||
}
|
||||
Zotero.logError(e);
|
||||
throw new Error("Invalid preference '" + pref + "'");
|
||||
throw new Error(`Error setting preference '${pref}'`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue