Closed
Bug 195355
Opened 22 years ago
Closed 21 years ago
listBoxObject.getRowCount() returns wrong value
Categories
(Core :: XUL, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: shanec, Assigned: neil)
References
Details
(Keywords: fixed1.7)
Attachments
(4 files)
809 bytes,
patch
|
Details | Diff | Splinter Review | |
564 bytes,
application/vnd.mozilla.xul+xml
|
Details | |
925 bytes,
application/vnd.mozilla.xul+xml
|
Details | |
980 bytes,
patch
|
janv
:
review+
Bienvenu
:
superreview+
asa
:
approval1.7+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3b) Gecko/20030210
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3b) Gecko/20030210
I discovered this while looking into keyboard navigation handling, I was getting
some exceptions in listboxes:
Komodo: Debug: (0): uncaught exception: [Exception... "Component returned failur
e code: 0x80004005 (NS_ERROR_FAILURE) [nsIListBoxObject.getItemAtIndex]" nsresu
lt: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://global/cont
ent/bindings/listbox.xml#listbox.getItemAtIndex() :: getItemAtIndex :: line 1"
data: no]
This is reproducable with a simple listbox, just select the first item, the
press the 'z' key to get the exception.
<listbox>
<listitem label="Normal"/>
<listitem label="Selected" selected="true" />
<listitem label="Disabled" disabled="true" />
<listitem label="Checkbox" class="listitem-iconic" type="checkbox"
image="images/betty_boop.xbm"/>
<listitem label="Checked" type="checkbox" checked="true" />
</listbox>
I tracked the exception down to the keypress handler in the listbox xbl,
rowCount is always higher than the actual rows in the listbox, then the call to
getItemAtIndex would of course fail. This is with a build from moz latest
downloaded a few hours ago.
It's not causing me any major problems, at least for now :)
Reproducible: Always
Steps to Reproduce:
Comment 1•22 years ago
|
||
-> varga
Assignee: jaggernaut → varga
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee | ||
Comment 2•22 years ago
|
||
I've seen a similar problem, the row count returned by getRowCount() is one less
than the actual number of rows in the listbox. In my case I think the error is
caused by line 1328 in nsListBoxBodyFrame.cpp which doesn't ensure that the row
count is accurate before modifying it.
Comment 3•22 years ago
|
||
WFM, can you still reproduce it ?
Assignee | ||
Comment 4•22 years ago
|
||
It's probably dependent on the order things happen, but I always see it on the
mailnews attachment list, if the very first message with attachments has three
or more, then the list thinks it has one fewer, possibly because it adds the 3
to the default value of -1, which means "count will be computed later".
Reporter | ||
Comment 5•22 years ago
|
||
Hmm, no I'm not able to easily reproduce it now (trunk as of last week).
Comment 6•22 years ago
|
||
Neil, I guess you already have something similar in your tree, but could you
try to reproduce the problem with this patch ?
Comment 7•22 years ago
|
||
getRowCount() returns 5 for me.
Comment 8•22 years ago
|
||
getRowCount() can also return a value greater than that required.
See the boiled-down test case that shows this. Apologies,
I only tested this on 1.3 final so far. View with -chrome.
This file may assist in confirming your fix works.
I wonder if the listbox "tallest row" calculations are getting knotted
up by the layout imposed by the listbox's sibling tag. That would
account for both getRowCount() problems and occassional odd layout
problems, and would be a more general issue than just getRowCount().
hope this helps. - N.
Assignee | ||
Comment 9•22 years ago
|
||
Jan, actually the way I fixed this variant was to use
if (mRowCount >= 0)
++mRowCount;
(similarly for the -- version)
But your patch works too...
Comment 10•21 years ago
|
||
FWIW, the too-large test case works for me under firebird 0.6.1 and win xp.
My own problem is that when using a template in a listbox (sorry don't have an
available test case) the numbers returns by this function vary if this is the
first time I open the window (in which I get the currect number) or its not (in
which I get one more then there is), since my base code is 1.2 I'm not sure that
it is relevent but from inspecting the code it seems that the code didn't change.
Comment 11•21 years ago
|
||
see also bug 122180
Comment 12•21 years ago
|
||
I'm going to request blocking here since not only is there a patch here, it
addresses the longstanding and much-duped bug 122180.
> Jan, actually the way I fixed this variant was to use
> if (mRowCount >= 0)
> ++mRowCount;
> (similarly for the -- version)
That implies that mRowCount will never be incremented if it's negative -- is
there a later call to ComputeRowCount(), as seen in Jan's patch, that takes care
of that issue?
Flags: blocking1.7?
Assignee | ||
Comment 13•21 years ago
|
||
(In reply to comment #12)
>is there a later call to ComputeRowCount(), as seen in Jan's patch, that
>takes care of that issue?
http://lxr.mozilla.org/seamonkey/source/layout/xul/base/src/nsListBoxBodyFrame.cpp
631 PRInt32
632 nsListBoxBodyFrame::GetRowCount()
633 {
634 if (mRowCount < 0)
635 ComputeTotalRowCount();
636 return mRowCount;
637 }
Comment 14•21 years ago
|
||
I think Neil's approach is better. We might need to add this check for
mRowCount-- too.
Assignee: varga → neil.parkwaycc.co.uk
Assignee | ||
Comment 15•21 years ago
|
||
Assignee | ||
Updated•21 years ago
|
Attachment #146703 -
Flags: review?(varga)
Updated•21 years ago
|
Attachment #146703 -
Flags: review?(varga) → review+
Updated•21 years ago
|
Attachment #146703 -
Flags: superreview+
Assignee | ||
Comment 16•21 years ago
|
||
Comment on attachment 146703 [details] [diff] [review]
Proposed patch
Low-risk fix for annoying attachment display issue.
Attachment #146703 -
Flags: approval1.7?
Assignee | ||
Comment 17•21 years ago
|
||
Fix checked in to the trunk.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Comment 18•21 years ago
|
||
Comment on attachment 146703 [details] [diff] [review]
Proposed patch
a=asa (on behalf of drivers) for checkin to 1.7
Attachment #146703 -
Flags: approval1.7? → approval1.7+
Updated•21 years ago
|
Flags: blocking1.7?
Comment 20•21 years ago
|
||
*** Bug 214685 has been marked as a duplicate of this bug. ***
You need to log in
before you can comment on or make changes to this bug.
Description
•