Fix UCI 'button' options

When a button fires UCIOption::operator=() is called and from
there the on_change() function. Now it happens that in case of
a button the on_change() function resets option's value to
"false" triggering again UCIOption::operator=() that calls again
on_change() and so on in an endless loop that is experienced
by the user as an application hang.

Rework the button logic to fix the issue and also be more clear
about how button works.

Reported by several people working with Scid and tracked down
to the "Clear Hash" UCI button by Steven Atkinson.

Bug recently introduced by 2ef5b4066e.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2012-03-17 10:29:33 +01:00
parent 9934b8ec31
commit ee838f56f7
2 changed files with 15 additions and 9 deletions

View File

@@ -30,12 +30,12 @@ struct OptionsMap;
/// UCIOption class implements an option as defined by UCI protocol
class UCIOption {
typedef void (Fn)(UCIOption&);
typedef void (Fn)(const UCIOption&);
public:
UCIOption() {} // Required by std::map::operator[]
UCIOption(const char* v, Fn* = NULL);
UCIOption(Fn* = NULL);
UCIOption(bool v, Fn* = NULL);
UCIOption(const char* v, Fn* = NULL);
UCIOption(int v, int min, int max, Fn* = NULL);
void operator=(const std::string& v);