Fix a hack implemented in wxEnumProperty::ValueFromString_ and wxEnumProperty::ValueFromInt_ functions.

wxEnumProperty code is refactored in order to fix a hack which purpose was (apparently) to bypass constness of these functions by caching determined indices in wxEnumProperty::ms_nextIndex static member variable for further processing. (Unclear concept of using this static member was referred in http://trac.wxwidgets.org/ticket/12779#comment:9)
Now, determined index is returned to the caller and processed there if necessary and hence caching of this index is not necessary.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78390 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek
2015-01-19 17:22:29 +00:00
parent eec7ef7232
commit 752938cecd
3 changed files with 51 additions and 42 deletions

View File

@@ -1454,13 +1454,11 @@ bool wxSystemColourProperty::StringToValue( wxVariant& value, const wxString& te
{
// This really should not occur...
// wxASSERT(false);
ResetNextIndex();
return false;
}
if ( !QueryColourFromUser(value) )
{
ResetNextIndex();
if ( !(argFlags & wxPG_PROPERTY_SPECIFIC) )
return false;
// If query for value comes from the event handler
@@ -1477,12 +1475,11 @@ bool wxSystemColourProperty::StringToValue( wxVariant& value, const wxString& te
if ( !conversionSuccess )
{
// Try predefined colour first
bool res = wxEnumProperty::StringToValue(value,
colStr,
argFlags);
if ( res && GetIndex() >= 0 )
int index;
bool res = ValueFromString_(value, &index, colStr, argFlags);
if ( res && index >= 0 )
{
val.m_type = GetIndex();
val.m_type = index;
if ( val.m_type < m_choices.GetCount() )
val.m_type = m_choices[val.m_type].GetValue();
@@ -1501,7 +1498,6 @@ bool wxSystemColourProperty::StringToValue( wxVariant& value, const wxString& te
if ( !done )
{
ResetNextIndex();
return false;
}