wxRadioButtons in the same group no longer have to be consecutive

(there may be intervening controls). Without this fix, an out-of-sync
assert is generated when clicking on a radio button and then calling
GetValue().


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29971 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2004-10-18 20:20:47 +00:00
parent f31424dbe9
commit c5b3143a47
2 changed files with 16 additions and 12 deletions

View File

@@ -227,6 +227,7 @@ wxMac:
wxMSW: wxMSW:
- fixed enhanced metafiles loading from files (Andreas Goebel) - fixed enhanced metafiles loading from files (Andreas Goebel)
- Group of wxRadioButtons no longer have to be consecutive
2.5.3 2.5.3

View File

@@ -182,13 +182,14 @@ void wxRadioButton::SetValue(bool value)
{ {
wxRadioButton *btn = wxDynamicCast(nodeBefore->GetData(), wxRadioButton *btn = wxDynamicCast(nodeBefore->GetData(),
wxRadioButton); wxRadioButton);
if ( !btn ) if ( btn && btn->HasFlag(wxRB_SINGLE) )
{ {
// the radio buttons in a group must be consecutive, so // A wxRB_SINGLE button isn't part of this group
// there are no more of them
break; break;
} }
if (btn)
{
btn->SetValue(false); btn->SetValue(false);
if ( btn->HasFlag(wxRB_GROUP) ) if ( btn->HasFlag(wxRB_GROUP) )
@@ -199,6 +200,7 @@ void wxRadioButton::SetValue(bool value)
} }
} }
} }
}
// ... and also turn off all buttons after this one // ... and also turn off all buttons after this one
for ( wxWindowList::compatibility_iterator nodeAfter = nodeThis->GetNext(); for ( wxWindowList::compatibility_iterator nodeAfter = nodeThis->GetNext();
@@ -208,12 +210,13 @@ void wxRadioButton::SetValue(bool value)
wxRadioButton *btn = wxDynamicCast(nodeAfter->GetData(), wxRadioButton *btn = wxDynamicCast(nodeAfter->GetData(),
wxRadioButton); wxRadioButton);
if ( !btn || btn->HasFlag(wxRB_GROUP) ) if ( btn && (btn->HasFlag(wxRB_GROUP) || btn->HasFlag(wxRB_SINGLE) ) )
{ {
// no more buttons or the first button of the next group // no more buttons or the first button of the next group
break; break;
} }
if (btn)
btn->SetValue(false); btn->SetValue(false);
} }
} }