From fdecb4a39f3e0340fe555797030454986b50be78 Mon Sep 17 00:00:00 2001 From: nerix Date: Mon, 13 May 2024 20:00:50 +0200 Subject: [PATCH] revert: use max(minimum, min(bottom, value)) over clamp(..) (#5393) --- CHANGELOG.md | 2 +- src/widgets/Scrollbar.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e6b65f6..66d5e9db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ - Dev: Use Qt's high DPI scaling. (#4868) - Dev: Add doxygen build target. (#5377) - Dev: Make printing of strings in tests easier. (#5379) -- Dev: Refactor and document `Scrollbar`. (#5334) +- Dev: Refactor and document `Scrollbar`. (#5334, #5393) ## 2.5.1 diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index e1492b67..827ea645 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -153,7 +153,9 @@ void Scrollbar::setPageSize(qreal value) void Scrollbar::setDesiredValue(qreal value, bool animated) { - value = std::clamp(value, this->minimum_, this->getBottom()); + // this can't use std::clamp, because minimum_ < getBottom() isn't always + // true, which is a precondition for std::clamp + value = std::max(this->minimum_, std::min(this->getBottom(), value)); if (areClose(this->currentValue_, value)) { // value has not changed