NoGUI: Fix ImGui assertion on confirm/error message

This commit is contained in:
Connor McLaughlin 2021-02-04 13:43:15 +10:00
parent 2029702eda
commit 0d911f1ccd

View file

@ -18,8 +18,9 @@
#include "frontend-common/vulkan_host_display.h" #include "frontend-common/vulkan_host_display.h"
#include <cinttypes> #include <cinttypes>
#include <cmath> #include <cmath>
#include <imgui.h> #include "imgui.h"
#include <imgui_stdlib.h> #include "imgui_internal.h"
#include "imgui_stdlib.h"
Log_SetChannel(NoGUIHostInterface); Log_SetChannel(NoGUIHostInterface);
#ifdef WIN32 #ifdef WIN32
@ -409,7 +410,9 @@ void NoGUIHostInterface::ReportError(const char* message)
if (!m_display) if (!m_display)
return; return;
ImGui::EndFrame(); const bool was_in_frame = GImGui->FrameCount != GImGui->FrameCountEnded;
if (was_in_frame)
ImGui::EndFrame();
bool done = false; bool done = false;
while (!done) while (!done)
@ -425,7 +428,8 @@ void NoGUIHostInterface::ReportError(const char* message)
m_display->Render(); m_display->Render();
} }
ImGui::NewFrame(); if (was_in_frame)
ImGui::NewFrame();
} }
bool NoGUIHostInterface::ConfirmMessage(const char* message) bool NoGUIHostInterface::ConfirmMessage(const char* message)
@ -435,7 +439,9 @@ bool NoGUIHostInterface::ConfirmMessage(const char* message)
if (!m_display) if (!m_display)
return true; return true;
ImGui::EndFrame(); const bool was_in_frame = GImGui->FrameCount != GImGui->FrameCountEnded;
if (was_in_frame)
ImGui::EndFrame();
bool done = false; bool done = false;
bool result = true; bool result = true;
@ -452,7 +458,9 @@ bool NoGUIHostInterface::ConfirmMessage(const char* message)
m_display->Render(); m_display->Render();
} }
ImGui::NewFrame(); if (was_in_frame)
ImGui::NewFrame();
return result; return result;
} }