Avoid spurious errors when getting wxChoice or wxListBox client data in wxMSW.

Even after the changes of r70415, we could still report an error when the
item client data was set to -1 (== CB_ERR) as checking for GetLastError() was
not enough, we need to also ensure that the last error is reset before trying
to get the client data.

Also apply the same fix to wxListBox and add the tests verifying that this
does work correctly.

Closes #13883.

Also fix wxListBox::GetClientData().

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74994 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-10-14 15:07:44 +00:00
parent 78a9e78ffd
commit 9d7f0c5f7e
3 changed files with 25 additions and 0 deletions

View File

@@ -200,6 +200,18 @@ void ItemContainerTestCase::VoidData()
WX_ASSERT_FAILS_WITH_ASSERT( container->SetClientData((unsigned)-1, NULL) );
WX_ASSERT_FAILS_WITH_ASSERT( container->SetClientData(12345, NULL) );
// wxMSW used to hace problems retrieving the client data of -1 from a few
// standard controls, especially if the last error was set before doing it,
// so test for this specially.
const wxUIntPtr minus1 = static_cast<wxUIntPtr>(-1);
container->Append("item -1", wxUIntToPtr(minus1));
#ifdef __WINDOWS__
::SetLastError(ERROR_INVALID_DATA);
#endif
CPPUNIT_ASSERT_EQUAL( minus1, wxPtrToUInt(container->GetClientData(3)) );
}
void ItemContainerTestCase::Set()