bug in Mozilla preferences ?
"met - Martin Hassman" <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.prefs |
|---|---|
| Organization | VSCHT |
| Message-ID | <[email protected]> |
Hi,
I think I have found a bug in the clearing of Mozilla preferences. Please can you give me your oppinion
before posting to the bugzilla?
This example creates "onlytest.debug.test1" Bool pref value, then clear it and try to write
"onlytest.debug.test1" Int pref value, this raises an exception, because Mozilla remember the old type
(Bool) until restart.
Example (also avilable on http://www.penguin.cz/~met/pub/prefbug.html):
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var test1 = "onlytest.debug.test1";
var pref = Components.classes["@mozilla.org/preferences;1"]
.getService(Components.interfaces.nsIPref);
dump(pref.GetPrefType(test1)+"\n"); // return 0 == does not exist
pref.SetBoolPref(test1, true);
dump(pref.GetPrefType(test1)+"\n"); // return 128 == boolean
pref.ClearUserPref(test1);
dump(pref.GetPrefType(test1)+"\n"); // return 128 == boolean - BUG ?! should be 0
pref.SetIntPref(test1, 42); // this raises an exception !!
I have same result when using nsIPrefBranch instead of nsIPref.
In the comment in nsIPrefBranch.idl is
-----
* Called to clear a user set value from a specific preference. This will, in
* effect, reset the value to the default value. If no default value exists
* the preference will cease to exist.
-----
So I thought when I clear value "onlytest.debug.test1" (which is only in user profile), Mozilla should
forget the Bool type also. But the result is different.
I have found a solution to use DeleteBranch("onlytest.debug.test1") instead of ClearUserPref
("onlytest.debug.test1") but this could be potential problem, because it could delete everything like
"onlytest.debug.test1*"
met - martin hassman
--
Martin Hassman
Institute of Chemical Technology in Prague
Department of Biochemistry and Microbiology
Jaky Internetovy prohlizec pouzivat? Zkuste Mozillu http://www.czilla.cz
Jabber: hassmanm(at)njs.netlab.cz, ICQ: #295399122