mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
ImGui: don't use textures for autocomplete if the loading failed
Otherwise the indices will be incorrect and will cause undefined behavior.
This commit is contained in:
parent
7f36220448
commit
0b8017d3e6
@ -392,7 +392,7 @@ void CConsole::DrawAutoCompletePanel(void)
|
||||
|
||||
ImGui::PushID(static_cast<int>(i));
|
||||
|
||||
if (con_autocomplete_window_textures.GetBool())
|
||||
if (m_autoCompleteTexturesLoaded && con_autocomplete_window_textures.GetBool())
|
||||
{
|
||||
// Show the flag texture before the cvar name.
|
||||
const int mainTexIdx = GetFlagTextureIndex(suggest.flags);
|
||||
@ -772,13 +772,14 @@ bool CConsole::LoadFlagIcons(void)
|
||||
ret = LoadTextureBuffer(reinterpret_cast<unsigned char*>(rFlagIcon.m_pData), // !TODO: Fall-back texture.
|
||||
static_cast<int>(rFlagIcon.m_nSize), &rFlagIcon.m_idIcon, &rFlagIcon.m_nWidth, &rFlagIcon.m_nHeight);
|
||||
|
||||
IM_ASSERT(ret);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
Assert(0, "Texture flags load failed for %i", i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_autoCompleteTexturesLoaded = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -149,6 +149,11 @@ private:
|
||||
// the autocomplete window to keep the current selection visible.
|
||||
bool m_autoCompletePosMoved;
|
||||
|
||||
// If the textures failed to load, this will remain false and no textures
|
||||
// will be drawn in the autocomplete window. This is because if one fails
|
||||
// to load, the indices will be incorrect.
|
||||
bool m_autoCompleteTexturesLoaded;
|
||||
|
||||
// The position and rect of the autocomplete window, the pos is set to that
|
||||
// of the input text field + an offset to move it under the item.
|
||||
ImVec2 m_autoCompleteWindowPos;
|
||||
|
Loading…
x
Reference in New Issue
Block a user