mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[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:
@@ -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) {
|
||||
|
||||
@@ -37,6 +37,7 @@ struct Context : public SavedSettings {
|
||||
std::string title;
|
||||
int defaultWidth;
|
||||
int defaultHeight;
|
||||
bool isPlatformRendering{false};
|
||||
|
||||
GLFWwindow* window = nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user