[img-editor] Fixed std::clamp() crash in photo editor

This commit is contained in:
Artem Bilous
2026-06-30 22:55:02 +02:00
committed by John Preston
parent 8a22f2c106
commit 54d4d8a03e
@@ -78,6 +78,8 @@ void ItemCanvas::computeContentRect(const QPointF &p) {
const auto sceneSize = scene()->sceneRect().size();
const auto contentLeft = std::max(0., _contentRect.x());
const auto contentTop = std::max(0., _contentRect.y());
const auto contentRight = contentLeft + _contentRect.width();
const auto contentBottom = contentTop + _contentRect.height();
_contentRect = QRectF(
QPointF(
std::clamp(p.x() - _brushMargins.left(), 0., contentLeft),
@@ -85,11 +87,11 @@ void ItemCanvas::computeContentRect(const QPointF &p) {
QPointF(
std::clamp(
p.x() + _brushMargins.right(),
contentLeft + _contentRect.width(),
std::min(contentRight, sceneSize.width()),
sceneSize.width()),
std::clamp(
p.y() + _brushMargins.bottom(),
contentTop + _contentRect.height(),
std::min(contentBottom, sceneSize.height()),
sceneSize.height())));
}