Closed
Bug 333689
Opened 19 years ago
Closed 19 years ago
[@ nsCertTree::ToggleOpenState]
Categories
(Core Graveyard :: Security: UI, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: timeless, Assigned: Gijs)
References
()
Details
(Keywords: coverity, crash)
Crash Data
Attachments
(1 file, 1 obsolete file)
|
1.13 KB,
patch
|
KaiE
:
review+
neil
:
superreview+
|
Details | Diff | Splinter Review |
this code is both silly and crashy. would someone please save it?
| Assignee | ||
Comment 1•19 years ago
|
||
I think this is enough to fix this bug. First C++ patch ever, though. So have mercy on my foolishness.
| Assignee | ||
Comment 2•19 years ago
|
||
Oops. Keeping this on people's radards.
Comment 3•19 years ago
|
||
Comment on attachment 218153 [details] [diff] [review]
Patch, I hope
r=kengert
Attachment #218153 -
Flags: review? → review+
Attachment #218153 -
Flags: superreview?(neil)
Comment 4•19 years ago
|
||
Comment on attachment 218153 [details] [diff] [review]
Patch, I hope
>- if (el) el->open = !el->open;
>- PRInt32 fac = (el->open) ? 1 : -1;
>- if (mTree) mTree->RowCountChanged(index, fac * el->numChildren);
>+ if (el) {
>+ el->open = !el->open;
>+ PRInt32 fac = (el->open) ? 1 : -1;
>+ if (mTree) mTree->RowCountChanged(index, fac * el->numChildren);
>+ }
> mSelection->Select(index);
My feeling is that this, the only call of mSelection in this file, is to work around the bug in the previous line. I won't keep you in suspense; the bug is that when you toggle a row then its children get added or removed after, not before the row, and thus the first parameter to RowCountChanged is 1 too low.
sr=me with that fixed, or better still if kaie warms to the idea of removing the call to mSelection->Select(index); too ;-) Oh, and I prefer the idea of el->open ? el->numChildren : -el->numChildren rather than the multiplication.
Attachment #218153 -
Flags: superreview?(neil) → superreview+
Comment 5•19 years ago
|
||
Neil, you say, in addition to the missing null check, you see an additional bug.
And you propose to fix that bug as well.
According to the explanation and examples on http://xulplanet.com/tutorials/xultu/treeviewdet.html I agree, the correct first parameter to RowCountChanged seems to be (index+1).
I agree we could simplify the code, and remove the multiplication.
I don't understand why you propose to remove the call to ->Select().
What happens if a child item is selected, and the parent is collapsed?
The selected child will no longer be visible.
I agree the authors of the intended to select the nearest reasonable item instead.
I'm fine with that, I propose we keep this behaviour unless there is a good reason.
So can we agree on this?
if (el) {
el->open = !el->open;
if (mTree) {
PRInt changeAmount = el->open ? el->numChildren : -el->numChildren;
mTree->RowCountChanged(index + 1, changeAmount);
}
}
mSelection->Select(index);
Comment 6•19 years ago
|
||
s/PRInt/PRInt32/
Comment 7•19 years ago
|
||
(In reply to comment #5)
>I don't understand why you propose to remove the call to ->Select().
>What happens if a child item is selected, and the parent is collapsed?
>The selected child will no longer be visible.
Actually trees already know about that, see
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/toolkit/content/widgets/tree.xml&rev=1.1&root=/cvsroot&mark=750-751#745
Comment 8•19 years ago
|
||
ok, I'm fine with removing the ->Select() call
| Assignee | ||
Comment 9•19 years ago
|
||
Someone had better test whether this compiles, since I want to go to bed and make doesn't like my ancient tree enough to do its work (and I really don't want to do a full new build and wait for an hour to tell if it works). My excuse for doing it at this horrific time of night is "timeless made me do it".
Attachment #218153 -
Attachment is obsolete: true
Attachment #221113 -
Flags: superreview?(neil)
Attachment #221113 -
Flags: review?
| Assignee | ||
Updated•19 years ago
|
Attachment #221113 -
Flags: review? → review?(kengert)
Updated•19 years ago
|
Attachment #221113 -
Flags: superreview?(neil) → superreview+
Comment 10•19 years ago
|
||
Comment on attachment 221113 [details] [diff] [review]
New Patch
it compiles
Attachment #221113 -
Flags: review?(kengert) → review+
| Assignee | ||
Comment 11•19 years ago
|
||
Yeah, so, timeless totally committed this on the 11th. Oops. Or something.
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/security/manager/ssl/src/nsCertTree.cpp&rev=1.47#872
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Updated•14 years ago
|
Crash Signature: [@ nsCertTree::ToggleOpenState]
Updated•9 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•