From 3c7ac73c5ee33dd7f0aa852b14c8a6c1e705ed19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 21 Dec 2016 16:46:22 +0100 Subject: [PATCH] [apps/statistics] Throw an error when the user set a negative value as bin width Change-Id: I0203ce403e469f4616af74399e451f6ed41d3024 --- apps/statistics/data.cpp | 3 +++ apps/statistics/histogram_parameter_controller.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/apps/statistics/data.cpp b/apps/statistics/data.cpp index 593967c31..3f6b5694b 100644 --- a/apps/statistics/data.cpp +++ b/apps/statistics/data.cpp @@ -27,6 +27,9 @@ float Data::binWidth() { } void Data::setBinWidth(float binWidth) { + if (binWidth <= 0.0f) { + return; + } m_binWidth = binWidth; computeYMax(); initSelectedBin(); diff --git a/apps/statistics/histogram_parameter_controller.cpp b/apps/statistics/histogram_parameter_controller.cpp index 3610120d6..8f93f12e7 100644 --- a/apps/statistics/histogram_parameter_controller.cpp +++ b/apps/statistics/histogram_parameter_controller.cpp @@ -32,6 +32,10 @@ float HistogramParameterController::parameterAtIndex(int index) { void HistogramParameterController::setParameterAtIndex(int parameterIndex, float f) { assert(parameterIndex >= 0 && parameterIndex < 2); if (parameterIndex == 0) { + if (f <= 0.0f) { + app()->displayWarning("Value interdite"); + return; + } m_data->setBinWidth(f); } else { m_data->setMinValue(f);