diff --git a/CHANGELOG.md b/CHANGELOG.md index 25b6a568e9..1759f78704 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ You can grab pre-release versions from PyPi. See the available versions from the Arcade [PyPi Release History](https://pypi.org/project/arcade/#history) page. +## Unreleased + +- Fixed an issue causing a crash when closing the window +- Added `Window.close` (bool) attribute indicating if the window is closed + ## Version 3.2 - GUI diff --git a/arcade/application.py b/arcade/application.py index 763661bd7d..4e77e047ea 100644 --- a/arcade/application.py +++ b/arcade/application.py @@ -172,6 +172,8 @@ def __init__( gl_version = 3, 1 gl_api = "gles" + self.closed = False + """Indicates if the window was closed""" self.headless: bool = arcade.headless """If True, the window is running in headless mode.""" @@ -429,6 +431,7 @@ def run(self, view: View | None = None) -> None: def close(self) -> None: """Close the Window.""" + self.closed = True super().close() # Make sure we don't reference the window any more set_window(None) @@ -537,7 +540,10 @@ def _dispatch_frame(self, delta_time: float) -> None: # we only need the modulus to keep time, if we didn't care # it could be set to zero instead. # ! This should maybe be fixed at 'self._draw_rate', discuss. - self.draw(self._accumulated_draw_time) + + # In case the window close in on_update, on_fixed_update or input callbacks + if not self.closed: + self.draw(self._accumulated_draw_time) self._accumulated_draw_time %= self._draw_rate def _dispatch_updates(self, delta_time: float) -> None: