From c013ee3778e35d8db5ed3c656d60655e2cb94306 Mon Sep 17 00:00:00 2001 From: wraitii Date: Fri, 11 Dec 2020 10:02:05 +0000 Subject: [PATCH] Fix usage of remove_if in CHotkeyPicker I was not aware of the erase-remove idiom and failed to notice that remove_if simply reorders the elements. Noted by Stan thanks to VS17 warnings. Fixes a4852c4c01 / D2814 This was SVN commit r24371. --- source/gui/ObjectTypes/CHotkeyPicker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/gui/ObjectTypes/CHotkeyPicker.cpp b/source/gui/ObjectTypes/CHotkeyPicker.cpp index 6640be5c73..4f6eca6c09 100644 --- a/source/gui/ObjectTypes/CHotkeyPicker.cpp +++ b/source/gui/ObjectTypes/CHotkeyPicker.cpp @@ -135,8 +135,8 @@ InReaction CHotkeyPicker::PreemptEvent(const SDL_Event_* ev) return IN_HANDLED; } // Don't handle keys and mouse together except for modifiers. - std::remove_if(m_KeysPressed.begin(), m_KeysPressed.end(), [](const Key& k) { - return static_cast(k.code) < UNIFIED_SHIFT || static_cast(k.code) >= UNIFIED_LAST; } ); + m_KeysPressed.erase(std::remove_if(m_KeysPressed.begin(), m_KeysPressed.end(), [](const Key& k) { + return static_cast(k.code) < UNIFIED_SHIFT || static_cast(k.code) >= UNIFIED_LAST; } ), m_KeysPressed.end()); m_KeysPressed.emplace_back(Key{scancode, FindScancodeName(scancode)}); // For mouse events, assume we immediately want to return. FireEvent(EventNameCombination);