From d5f3228ab0d95b8231f6a3e2d24e2793d3ca4608 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 15 May 2023 09:54:18 +0200 Subject: [PATCH] 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. --- r5dev/gameui/IBrowser.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/r5dev/gameui/IBrowser.cpp b/r5dev/gameui/IBrowser.cpp index b295e5a9..32a6ce4b 100644 --- a/r5dev/gameui/IBrowser.cpp +++ b/r5dev/gameui/IBrowser.cpp @@ -78,7 +78,11 @@ bool CBrowser::Init(void) SetStyleVar(); m_szMatchmakingHostName = pylon_matchmaking_hostname->GetString(); - return true; + bool ret = LoadTextureBuffer(reinterpret_cast(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(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)));