Check index in wxItemContainer methods working with client data.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 10 Jan 2011 12:00:54 +0000 (12:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 10 Jan 2011 12:00:54 +0000 (12:00 +0000)
commit8584b0e64b273273bad122d28b10176bd5a3bc84
treed0abf6f426169e9e1658b9f4328b6fda8ebfaf95
parentca275c039c9e53bd37c008a19e30c382fbb65895
Check index in wxItemContainer methods working with client data.

The test for index validity should be done by the base class public methods
themselves so that the protected methods in the derived classes don't need to
do it because this allows to have the check in one place only and not in every
port-specific derived class and also because a protected method can reasonably
expect to be called with already validated parameters.

This makes it unnecessary to perform the same check in many derived classes
and fixes the problem with those that forgot to check for item validity at all
before (like wxGTK wxChoice).

Also add a unit test checking for the correct behaviour. Unfortunately we
don't have any way to test for the precise assert being triggered so the test
passed for wxGTK wxChoice even before in debug builds because the expected
assert was raised by wxArray::Item() but the code crashed in release build --
whereas now it doesn't any more.

Closes #12858.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66664 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
src/common/ctrlsub.cpp
src/gtk/listbox.cpp
src/msw/listbox.cpp
src/osx/choice_osx.cpp
src/osx/combobox_osx.cpp
tests/controls/itemcontainertest.cpp