Fix intermittent bug in server browser

On some compile runs, the 'LoadTextureBuffer' call is getting optimized out as 'ret' is only used for the assert statement, but on release, the assert statements does nothing and thus the compiler got rid of the call. This code should not be fired in this function, but rather in the initialization routine anyways. The code has been moved to 'CBrowser::Init', and the issue has been fixed.
This commit is contained in:
Kawe Mazidjatari 2023-05-15 09:54:18 +02:00
parent f943fe8509
commit d5f3228ab0

View File

@ -78,7 +78,11 @@ bool CBrowser::Init(void)
SetStyleVar();
m_szMatchmakingHostName = pylon_matchmaking_hostname->GetString();
return true;
bool ret = LoadTextureBuffer(reinterpret_cast<unsigned char*>(m_rLockedIconBlob.m_pData), int(m_rLockedIconBlob.m_nSize),
&m_idLockedIcon, &m_rLockedIconBlob.m_nWidth, &m_rLockedIconBlob.m_nHeight);
IM_ASSERT(ret && m_idLockedIcon);
return ret;
}
//-----------------------------------------------------------------------------
@ -399,15 +403,6 @@ void CBrowser::HiddenServersModal(void)
if (ImGui::BeginPopupModal("Private Server", &bModalOpen, ImGuiWindowFlags_NoResize))
{
ImGui::SetWindowSize(ImVec2(408.f, flHeight), ImGuiCond_Always);
if (!m_idLockedIcon) // !TODO: Fall-back texture.
{
bool ret = LoadTextureBuffer(reinterpret_cast<unsigned char*>(m_rLockedIconBlob.m_pData), int(m_rLockedIconBlob.m_nSize),
&m_idLockedIcon, &m_rLockedIconBlob.m_nWidth, &m_rLockedIconBlob.m_nHeight);
IM_ASSERT(ret);
NOTE_UNUSED(ret);
}
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.00f, 0.00f, 0.00f, 0.00f)); // Override the style color for child bg.
ImGui::BeginChild("##HiddenServersConnectModal_IconParent", ImVec2(float(m_rLockedIconBlob.m_nWidth), float(m_rLockedIconBlob.m_nHeight)));