From 448fbe44e91375669e2fd6677475ffe724b94724 Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Mon, 16 Mar 2015 15:55:36 +0300 Subject: [PATCH] Improve CButton::block and fix CToggleGroup->selectedID CToggleGroup. Originally when I added initialization for selectedID I didn't find out that -1 is used for "random" buttons. So as result I fixed uninitialized variable usage, but break initial button state change in RMG options because setSelected ignore state change request because it's see -1 button already marked as selected. --- client/widgets/Buttons.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/widgets/Buttons.cpp b/client/widgets/Buttons.cpp index 42c01d2cf..9504cfe73 100644 --- a/client/widgets/Buttons.cpp +++ b/client/widgets/Buttons.cpp @@ -144,7 +144,8 @@ bool CButton::isHighlighted() void CButton::block(bool on) { - setState(on?BLOCKED:NORMAL); + if(on || state == BLOCKED) //dont change button state if unblock requested, but it's not blocked + setState(on ? BLOCKED : NORMAL); } void CButton::onButtonClicked() @@ -424,7 +425,7 @@ void CToggleGroup::addToggle(int identifier, CToggleBase* bt) } CToggleGroup::CToggleGroup(const CFunctionList &OnChange, bool musicLikeButtons) -: onChange(OnChange), selectedID(-1), musicLike(musicLikeButtons) +: onChange(OnChange), selectedID(-2), musicLike(musicLikeButtons) {} void CToggleGroup::setSelected(int id)