Don't assert if config file contains an invalid boolean value.

Asserts should be only triggered by programming errors, not by user actions,
and the assert checking that the value is either 0 or 1 in
wxConfigBase::DoReadBool() could happen if the user edited the file and put a
wrong value into it.

Replace the assert with a warning message.

See #11437.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66140 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2010-11-13 15:03:10 +00:00
parent 65571ec7bf
commit 0231d18f1a

View File

@ -221,7 +221,15 @@ bool wxConfigBase::DoReadBool(const wxString& key, bool* val) const
if ( !DoReadLong(key, &l) )
return false;
wxASSERT_MSG( l == 0 || l == 1, wxT("bad bool value in wxConfig::DoReadInt") );
if ( l != 0 && l != 1 )
{
// Don't assert here as this could happen in the result of user editing
// the file directly and this not indicate a bug in the program but
// still complain that something is wrong.
wxLogWarning(_("Invalid value %ld for a boolean key \"%s\" in "
"config file."),
l, key);
}
*val = l != 0;