[or-cvs] r20183: {torbutton} Workaround for Bug 1006 and possibly 1012 to allow toggle to (torbutton/trunk/src/chrome/content)
mikeperry at seul.org
mikeperry at seul.org
Tue Jul 28 21:39:06 UTC 2009
Author: mikeperry
Date: 2009-07-28 17:39:05 -0400 (Tue, 28 Jul 2009)
New Revision: 20183
Modified:
torbutton/trunk/src/chrome/content/torbutton.js
Log:
Workaround for Bug 1006 and possibly 1012 to allow
toggle to continue after popping up a more specific
alert.
Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js 2009-07-28 20:10:03 UTC (rev 20182)
+++ torbutton/trunk/src/chrome/content/torbutton.js 2009-07-28 21:39:05 UTC (rev 20183)
@@ -744,63 +744,88 @@
}
}
+// XXX: Hrmm, this may not always be called with ints (see bug 1006).
+// Possibly because some other addon sets odd values for a pref
+// that can be either int or char? Can maybe just wrap in try block
+// for now.
function torbutton_setIntPref(pref, save, val, mode, changed) {
if(!changed) return; // Handle the pref change cases via observers
- if(mode) {
- if(m_tb_prefs.prefHasUserValue(pref)) {
- m_tb_prefs.setIntPref("extensions.torbutton.saved."+save,
- m_tb_prefs.getIntPref(pref));
- } else if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
- m_tb_prefs.clearUserPref("extensions.torbutton.saved."+save);
+ try {
+ if(mode) {
+ if(m_tb_prefs.prefHasUserValue(pref)) {
+ m_tb_prefs.setIntPref("extensions.torbutton.saved."+save,
+ m_tb_prefs.getIntPref(pref));
+ } else if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+ m_tb_prefs.clearUserPref("extensions.torbutton.saved."+save);
+ }
+ m_tb_prefs.setIntPref(pref, val);
+ } else {
+ if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+ m_tb_prefs.setIntPref(pref,
+ m_tb_prefs.getIntPref("extensions.torbutton.saved."+save));
+ } else if(m_tb_prefs.prefHasUserValue(pref)) {
+ m_tb_prefs.clearUserPref(pref);
+ }
}
- m_tb_prefs.setIntPref(pref, val);
- } else {
- if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
- m_tb_prefs.setIntPref(pref,
- m_tb_prefs.getIntPref("extensions.torbutton.saved."+save));
- } else if(m_tb_prefs.prefHasUserValue(pref)) {
- m_tb_prefs.clearUserPref(pref);
- }
+ } catch(e) {
+ var msg = "Torbutton BUG: torbutton_setIntPref failed for "+pref
+ +"/"+save+" to value "+val+": "+e;
+ torbutton_log(5, msg);
+ window.alert(msg);
}
}
function torbutton_setCharPref(pref, save, val, mode, changed) {
if(!changed) return; // Handle the pref change cases via observers
- if(mode) {
- if(m_tb_prefs.prefHasUserValue(pref)) {
- m_tb_prefs.setCharPref("extensions.torbutton.saved."+save,
- m_tb_prefs.getCharPref(pref));
- } else if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
- m_tb_prefs.clearUserPref("extensions.torbutton.saved."+save);
+ try {
+ if(mode) {
+ if(m_tb_prefs.prefHasUserValue(pref)) {
+ m_tb_prefs.setCharPref("extensions.torbutton.saved."+save,
+ m_tb_prefs.getCharPref(pref));
+ } else if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+ m_tb_prefs.clearUserPref("extensions.torbutton.saved."+save);
+ }
+ m_tb_prefs.setCharPref(pref, val);
+ } else {
+ if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+ m_tb_prefs.setCharPref(pref,
+ m_tb_prefs.getCharPref("extensions.torbutton.saved."+save));
+ } else if(m_tb_prefs.prefHasUserValue(pref)) {
+ m_tb_prefs.clearUserPref(pref);
+ }
}
- m_tb_prefs.setCharPref(pref, val);
- } else {
- if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
- m_tb_prefs.setCharPref(pref,
- m_tb_prefs.getCharPref("extensions.torbutton.saved."+save));
- } else if(m_tb_prefs.prefHasUserValue(pref)) {
- m_tb_prefs.clearUserPref(pref);
- }
+ } catch(e) {
+ var msg = "Torbutton BUG: torbutton_setCharPref failed for "+pref
+ +"/"+save+" to value "+val+": "+e;
+ torbutton_log(5, msg);
+ window.alert(msg);
}
}
function torbutton_setBoolPref(pref, save, val, mode, changed) {
if(!changed) return; // Handle the pref change cases via observers
- if(mode) {
- if(m_tb_prefs.prefHasUserValue(pref)) {
- m_tb_prefs.setBoolPref("extensions.torbutton.saved."+save,
- m_tb_prefs.getBoolPref(pref));
- } else if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
- m_tb_prefs.clearUserPref("extensions.torbutton.saved."+save);
+ try {
+ if(mode) {
+ if(m_tb_prefs.prefHasUserValue(pref)) {
+ m_tb_prefs.setBoolPref("extensions.torbutton.saved."+save,
+ m_tb_prefs.getBoolPref(pref));
+ } else if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+ m_tb_prefs.clearUserPref("extensions.torbutton.saved."+save);
+ }
+ m_tb_prefs.setBoolPref(pref, val);
+ } else {
+ if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
+ m_tb_prefs.setBoolPref(pref,
+ m_tb_prefs.getBoolPref("extensions.torbutton.saved."+save));
+ } else if(m_tb_prefs.prefHasUserValue(pref)) {
+ m_tb_prefs.clearUserPref(pref);
+ }
}
- m_tb_prefs.setBoolPref(pref, val);
- } else {
- if(m_tb_prefs.prefHasUserValue("extensions.torbutton.saved."+save)) {
- m_tb_prefs.setBoolPref(pref,
- m_tb_prefs.getBoolPref("extensions.torbutton.saved."+save));
- } else if(m_tb_prefs.prefHasUserValue(pref)) {
- m_tb_prefs.clearUserPref(pref);
- }
+ } catch(e) {
+ var msg = "Torbutton BUG: torbutton_setBoolPref failed for "+pref
+ +"/"+save+" to value "+val+": "+e;
+ torbutton_log(5, msg);
+ window.alert(msg);
}
}
More information about the tor-commits
mailing list