From d282cc96579ff36f00b4c2f1c9aea3cdca9dfa64 Mon Sep 17 00:00:00 2001 From: Kvaz1r Date: Sat, 19 Aug 2023 18:16:39 +0300 Subject: [PATCH] Fix creating wxRadioBox with no items in wxUniv Don't select the first item if there are no items at all. Closes #23784. --- src/univ/radiobox.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/univ/radiobox.cpp b/src/univ/radiobox.cpp index 3838f50c48..b68ad2d097 100644 --- a/src/univ/radiobox.cpp +++ b/src/univ/radiobox.cpp @@ -162,8 +162,10 @@ bool wxRadioBox::Create(wxWindow *parent, wxSize actualSize = GetSize(); DoMoveWindow(actualPos.x, actualPos.y, actualSize.x, actualSize.y); - // radiobox should already have selection so select at least one item - SetSelection(0); + // Select first radio button if we have any buttons at all, as the radiobox + // should always have some selection. + if ( n != 0 ) + SetSelection(0); return true; }