From 5ae2e444f2bb6708da150bc49e100f7305656c18 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 30 Nov 2023 11:23:15 -0300 Subject: [PATCH] Replace asserts limiting values directly in Entry::selectedRange() There are some cases where these asserts failed (mainly in the dithering matrix selection combobox). --- src/ui/entry.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/entry.cpp b/src/ui/entry.cpp index 00a5f78eb..5464be304 100644 --- a/src/ui/entry.cpp +++ b/src/ui/entry.cpp @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2018-2022 Igara Studio S.A. +// Copyright (C) 2018-2023 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This file is released under the terms of the MIT license. @@ -195,8 +195,8 @@ Entry::Range Entry::selectedRange() const range.from = std::min(m_caret, m_select); range.to = std::max(m_caret, m_select); - ASSERT(range.from >= 0 && range.from < int(m_boxes.size())); - ASSERT(range.to >= 0 && range.to <= int(m_boxes.size())); + range.from = std::clamp(range.from, 0, std::max(0, int(m_boxes.size())-1)); + range.to = std::clamp(range.to, 0, int(m_boxes.size())); } return range; }