From 6a6dd0888ad91ff85a580c12d469afff1789788e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 4 Jan 2021 00:09:28 +0100 Subject: statistics: don't reset binner if binner is set Recently code was added to reset variable 1 binner if the second variable does not support an unbinned first variable. It forgot to check whether a binner was already set. Do this. But validate the old binner first! This code is extremely fragile and will have to be redone. Signed-off-by: Berthold Stoeger --- stats/statsstate.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'stats/statsstate.cpp') diff --git a/stats/statsstate.cpp b/stats/statsstate.cpp index 5522ebc5a..130a0e5a8 100644 --- a/stats/statsstate.cpp +++ b/stats/statsstate.cpp @@ -557,9 +557,11 @@ void StatsState::validate(bool varChanged) if (var1 == var2) var2 = nullptr; + validateBinner(var1Binner, var1, false); + // If there is no second variable or the second variable is not // "numeric", the first variable must be binned. - if (!var2 || var2->type() != StatsVariable::Type::Numeric) + if ((!var2 || var2->type() != StatsVariable::Type::Numeric) && !var1Binner) var1Binner = getFirstBinner(var1); // Check that the binners and operation are valid @@ -567,7 +569,6 @@ void StatsState::validate(bool varChanged) var2Binner = nullptr; // Second variable can only be binned if first variable is binned. var2Operation = StatsOperation::Invalid; } - validateBinner(var1Binner, var1, false); validateBinner(var2Binner, var2, true); validateOperation(var2Operation, var2, var1Binner); -- cgit v1.2.3-70-g09d2