From c5b3143a47afa4dfab849e465cbd46e8a331a41b Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Mon, 18 Oct 2004 20:20:47 +0000 Subject: [PATCH] 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 --- docs/changes.txt | 1 + src/msw/radiobut.cpp | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 5929be270b..86c8f32d54 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -227,6 +227,7 @@ wxMac: wxMSW: - fixed enhanced metafiles loading from files (Andreas Goebel) +- Group of wxRadioButtons no longer have to be consecutive 2.5.3 diff --git a/src/msw/radiobut.cpp b/src/msw/radiobut.cpp index df5468f000..2b3b4925cc 100644 --- a/src/msw/radiobut.cpp +++ b/src/msw/radiobut.cpp @@ -182,20 +182,22 @@ void wxRadioButton::SetValue(bool value) { wxRadioButton *btn = wxDynamicCast(nodeBefore->GetData(), wxRadioButton); - if ( !btn ) + if ( btn && btn->HasFlag(wxRB_SINGLE) ) { - // the radio buttons in a group must be consecutive, so - // there are no more of them + // A wxRB_SINGLE button isn't part of this group break; } - - btn->SetValue(false); - - if ( btn->HasFlag(wxRB_GROUP) ) + + if (btn) { - // even if there are other radio buttons before this one, - // they're not in the same group with us - break; + btn->SetValue(false); + + if ( btn->HasFlag(wxRB_GROUP) ) + { + // even if there are other radio buttons before this one, + // they're not in the same group with us + break; + } } } } @@ -208,13 +210,14 @@ void wxRadioButton::SetValue(bool value) wxRadioButton *btn = wxDynamicCast(nodeAfter->GetData(), 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 break; } - btn->SetValue(false); + if (btn) + btn->SetValue(false); } } } -- 2.45.2