[ wxwindows-Bugs-1841939 ] wxVListBox crash on mouse click

SourceForge.net noreply at sourceforge.net
Sat Dec 1 14:58:47 PST 2007


Bugs item #1841939, was opened at 2007-11-30 13:17
Message generated for change (Comment added) made by bpetty
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1841939&group_id=9863

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: wxMSW specific
Group: Must fix
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Kervala (kervala)
Assigned to: Nobody/Anonymous (nobody)
Summary: wxVListBox crash on mouse click

Initial Comment:
I tried with SVN trunk branch and this issue occured since 1-2 month on wxMSW (I didn't test it under Mac OS or Linux).

In a wxVListBox inherited class, when you click on the control with less than 10 elements, the application crash (a wxASSERT is shown). It seems like all mouse clicks are selecting the 10th element of the control event if it doesn't exist. If you move the selection with the keyboard, it doesn't crash and it selects the right elements.

All 2.8.x versions are fine.

Thanks in advance for fixing this bug.

----------------------------------------------------------------------

Comment By: Bryan Petty (bpetty)
Date: 2007-12-01 15:58

Message:
Logged In: YES 
user_id=1106696
Originator: NO

Sorry, looks like this if my fault, I made sure to note this required
change in the documentation [1], but forgot to update all internal
wxWidgets use of wxVScrolledWindow::HitTest(). I've committed a fix
including your change (and an additional one in wxVListBox) as well as
fixing wxHtmlListBox too, which also suffered from this change.

[1] http://urlx.org/lpthe.jussieu.fr/b1dd3

Thanks for spotting this.

This bug can be closed.

----------------------------------------------------------------------

Comment By: Kervala (kervala)
Date: 2007-12-01 04:56

Message:
Logged In: YES 
user_id=1678419
Originator: YES

File Added: vlbox.patch

----------------------------------------------------------------------

Comment By: Kervala (kervala)
Date: 2007-12-01 04:54

Message:
Logged In: YES 
user_id=1678419
Originator: YES

I fixed the bug by replacing HitTest by VirtualHitTest which returns the
correct item number.

Please can you verify if it's correct and apply it on svn ?

Thanks

File Added: vlbox.patch

----------------------------------------------------------------------

Comment By: Kervala (kervala)
Date: 2007-12-01 04:25

Message:
Logged In: YES 
user_id=1678419
Originator: YES

After further debugging, wxVListBox::OnLeftDown is calling
wxWindowBase::DoHitTest which returns wxHT_WINDOW_INSIDE (= 10) instead of
index of the item, so each mouse left click selects the 10th (or 11th)
element which is incorrect behavior.

----------------------------------------------------------------------

Comment By: Kervala (kervala)
Date: 2007-11-30 13:49

Message:
Logged In: YES 
user_id=1678419
Originator: YES

The assert message I got is :

21:44:15: ..\..\src\generic\vlbox.cpp(220): assert "current == wxNOT_FOUND
|| (current >= 0 && (size_t)current < GetItemCount())" failed in
wxVListBox::DoSetCurrent(): wxVListBox::DoSetCurrent(): invalid item index

When I follow the calls, I got current == 10 but the control has no
element. When the control has more than 10 elements, I can click on any of
them and only the 10th is selected.

I attached a sample which reproduces the bug.

File Added: test.cpp

----------------------------------------------------------------------

Comment By: Kervala (kervala)
Date: 2007-11-30 13:49

Message:
Logged In: YES 
user_id=1678419
Originator: YES

Please provide a small (this is important!) patch to a sample
reproducing the problem. Without being able to reproduce the bug
it is difficult to do anything about it.

----------------------------------------------------------------------

Comment By: Vadim Zeitlin (vadz)
Date: 2007-11-30 13:21

Message:
Logged In: YES 
user_id=71618
Originator: NO

Is it reproducible in the sample? If so, can you please make a patch
showing it?

Also, assert is not a crash. At the very least it provides information
which crash doesn't, such as file name and the line number where it
happened and the condition which failed. It would be useful to have it.

Thanks

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1841939&group_id=9863




More information about the wx-dev mailing list