summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-04 00:09:28 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-03 15:41:36 -0800
commit6a6dd0888ad91ff85a580c12d469afff1789788e (patch)
tree2062b99f1eede5c3d6d170c54958d1eb4f6ba275
parent77bc0c7c9396f82a4dccac0661adb05814909bb6 (diff)
downloadsubsurface-6a6dd0888ad91ff85a580c12d469afff1789788e.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
-rw-r--r--stats/statsstate.cpp5
1 files changed, 3 insertions, 2 deletions
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);