From a63b020e536e694225a4f695209bfad7c66b2cc4 Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Fri, 24 Nov 2023 22:58:17 +0100 Subject: [PATCH] glfw: fix crash when window size is <= 0 Windows sets the window size to (0,0) when minimizing the window. That leads to eventual division by zero errors and opengl does not want to attach a framebuffer with that size, resulting in it being incomplete. After maximizing again, it tries to unload that framebuffer, but it was never loaded. Minosoft crashes with an invalid framebuffer state: deleted --- .../minosoft/gui/rendering/system/window/glfw/GLFWWindow.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/system/window/glfw/GLFWWindow.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/system/window/glfw/GLFWWindow.kt index 899eb90c4..70dec28c9 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/system/window/glfw/GLFWWindow.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/system/window/glfw/GLFWWindow.kt @@ -351,8 +351,10 @@ class GLFWWindow( if (window != this.window) { return } - val previousSize = Vec2i(_size) val nextSize = unscalePosition(Vec2i(width, height)) + if (nextSize.x <= 0 || nextSize.y <= 0) return // windows returns size (0,0) if minimized + val previousSize = Vec2i(_size) + if (previousSize == nextSize) return _size = nextSize fireGLFWEvent(ResizeWindowEvent(context, previousSize = previousSize, size = _size)) this.skipNextMouseEvent = true