From 6a0dae416a2a268bac9ab6a9c72dcf8f9bff6e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Mustoha?= Date: Mon, 1 Apr 2024 22:11:06 +0200 Subject: [PATCH] Fixed a possible crash when the index is not reset on a search field --- src/common/ui/MI_SelectField.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/ui/MI_SelectField.cpp b/src/common/ui/MI_SelectField.cpp index 1a893cb0..11ff76fc 100644 --- a/src/common/ui/MI_SelectField.cpp +++ b/src/common/ui/MI_SelectField.cpp @@ -221,12 +221,16 @@ T MI_SelectField::randomValue() const template bool MI_SelectField::setCurrentValue(T value) { + const size_t prev_idx = m_index; + for (m_index = 0; m_index < m_items.size(); m_index++) { if (m_items[m_index].value == value) { updateOutput(); return true; } } + + m_index = prev_idx; return false; }