[wpigui] Don't recursively render frames in size callback (#3743)

WindowSizeCallback can sometimes be called while doing a render. If this occurs, imgui asserts. Avoid this case.
This commit is contained in:
Thad House
2021-11-28 01:03:40 -08:00
committed by GitHub
parent ae208d2b17
commit 4ba80a3a8c
2 changed files with 6 additions and 1 deletions

View File

@@ -34,7 +34,9 @@ static void WindowSizeCallback(GLFWwindow* window, int width, int height) {
gContext->width = width;
gContext->height = height;
}
PlatformRenderFrame();
if (!gContext->isPlatformRendering) {
PlatformRenderFrame();
}
}
static void FramebufferSizeCallback(GLFWwindow* window, int width, int height) {
@@ -291,7 +293,9 @@ void gui::Main() {
while (!glfwWindowShouldClose(gContext->window) && !gContext->exit) {
// Poll and handle events (inputs, window resize, etc.)
glfwPollEvents();
gContext->isPlatformRendering = true;
PlatformRenderFrame();
gContext->isPlatformRendering = false;
// custom saving
if (gContext->saveSettings) {

View File

@@ -37,6 +37,7 @@ struct Context : public SavedSettings {
std::string title;
int defaultWidth;
int defaultHeight;
bool isPlatformRendering{false};
GLFWwindow* window = nullptr;