From f1c0109c89f8e85d23c9addd11fc7412c3ca4dc7 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 15 May 2025 02:18:08 +0800 Subject: [PATCH] system/ui: Fix crash when exiting the application with CTRL+C (KeyboardInterrupt). (#35221) handle KeyboardInterrupt --- system/ui/lib/application.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/system/ui/lib/application.py b/system/ui/lib/application.py index ba1441170b..fb7f7832a4 100644 --- a/system/ui/lib/application.py +++ b/system/ui/lib/application.py @@ -131,17 +131,20 @@ class GuiApplication: rl.close_window() def render(self): - while not (self._window_close_requested or rl.window_should_close()): - rl.begin_drawing() - rl.clear_background(rl.BLACK) + try: + while not (self._window_close_requested or rl.window_should_close()): + rl.begin_drawing() + rl.clear_background(rl.BLACK) - yield + yield - if DEBUG_FPS: - rl.draw_fps(10, 10) + if DEBUG_FPS: + rl.draw_fps(10, 10) - rl.end_drawing() - self._monitor_fps() + rl.end_drawing() + self._monitor_fps() + except KeyboardInterrupt: + pass def font(self, font_weight: FontWeight=FontWeight.NORMAL): return self._fonts[font_weight]