From 7ff62348dfdae0ce89f5798d2e2c7ad5aaa62809 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 3 Feb 2022 07:53:38 +0100 Subject: [PATCH] App: fix ColorField::set/ColorGradient::set in case an invalid value range s passed --- src/App/ColorModel.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/App/ColorModel.cpp b/src/App/ColorModel.cpp index 4b6ff2e1b4..3f5c47975c 100644 --- a/src/App/ColorModel.cpp +++ b/src/App/ColorModel.cpp @@ -106,12 +106,15 @@ ColorField& ColorField::operator = (const ColorField &rclCF) void ColorField::set (const ColorModel &rclModel, float fMin, float fMax, std::size_t usCt) { - colorModel = rclModel; - this->fMin = std::min(fMin, fMax); - this->fMax = std::max(fMin, fMax); - if (this->fMax <= this->fMin) { + fMin = std::min(fMin, fMax); + fMax = std::max(fMin, fMax); + if (fMax <= fMin) { throw Base::ValueError("Maximum must be higher than minimum"); } + + this->fMin = fMin; + this->fMax = fMax; + colorModel = rclModel; ctColors = std::max(usCt, colorModel.getCountColors()); rebuild(); } @@ -209,11 +212,14 @@ std::vector ColorGradient::getColorModelNames() const void ColorGradient::set (float fMin, float fMax, std::size_t usCt, TStyle tS, bool bOG) { - _fMin = std::min(fMin, fMax); - _fMax = std::max(fMin, fMax); - if (_fMax <= _fMin) { + fMin = std::min(fMin, fMax); + fMax = std::max(fMin, fMax); + if (fMax <= fMin) { throw Base::ValueError("Maximum must be higher than minimum"); } + + _fMin = fMin; + _fMax = fMax; ctColors = std::max(usCt, getMinColors()); tStyle = tS; outsideGrayed = bOG;