Closed
Bug 80108
Opened 23 years ago
Closed 23 years ago
deleteBranch method of nsIPrefBranch does not work when null or "" is passed.
Categories
(Core :: Preferences: Backend, defect, P3)
Core
Preferences: Backend
Tracking
()
RESOLVED
FIXED
mozilla0.9.2
People
(Reporter: dsirnapalli, Assigned: bnesse)
References
Details
(Whiteboard: [r][sr][a])
Attachments
(2 files)
938 bytes,
patch
|
Details | Diff | Splinter Review | |
1.40 KB,
patch
|
Details | Diff | Splinter Review |
I used the piece of code below to test deleteBranch method. var nsIPrefBranchObj = nsIPrefServiceObj.getBranch("font."); nsIPrefBranchObj.deleteBranch(null); nsIPrefServiceObj.savePrefFile(null); Since the root is set "font." and null is passed to deleteBranch method,all of the preferences related to "font" such as "font.name.sans-serif.x-western", "font.size.fixed.x-western" and "font.size.variable.x-western" should be removed, but is not removing. Even if i use deleteBranch("") its not removing. it works if i pass a string like deleteBranch("size").
Assignee | ||
Comment 1•23 years ago
|
||
This is because the old 4.x pref code (which prefBranch is calling) is adding a "." to whatever is passed in. This will work if you create the service using "" and pass "font" in to the DeleteBranch call. The underlying code needs to be fixed so it only appends the "." if the last character isn't already a "."
Status: NEW → ASSIGNED
Component: Embedding APIs → Preferences: Backend
OS: Windows NT → All
Priority: -- → P3
Hardware: PC → All
Target Milestone: --- → mozilla0.9.2
Assignee | ||
Comment 2•23 years ago
|
||
Comment 3•23 years ago
|
||
Since this line: char* branch_dot = PR_smprintf("%s.", branch_name); appends a dot onto branch_name and returns the result, wouldn't you want to check for the dot first and then not append (which alocates memory) unless you had to. It seems that unconditionally appending the dot and then trimming it is wasteful.
Assignee | ||
Comment 4•23 years ago
|
||
I agree it's wasteful, but I was trying not to rearchitect the whole function. I'll work up a patch that works the other way for comparison.
Assignee | ||
Comment 5•23 years ago
|
||
Comment 6•23 years ago
|
||
That's good. Man, moral of the story is: if this code was C++ instead of C and we could use nifty nsStrings and string iterators, life would be better. r=ccarlen
Assignee | ||
Comment 7•23 years ago
|
||
Someday maybe, but not today. :)
Comment 8•23 years ago
|
||
good god :) sr=alecf
Assignee | ||
Updated•23 years ago
|
Whiteboard: [r][sr][need drivers approval]
a=dbaron for trunk checkin (on behalf of drivers)
Whiteboard: [r][sr][need drivers approval] → [r][sr][a]
Assignee | ||
Comment 10•23 years ago
|
||
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•