From 1e6e925d08da4b008b2daa8f9987b2d8458d071f Mon Sep 17 00:00:00 2001 From: Ry Date: Wed, 28 Dec 2022 00:05:15 -0800 Subject: [PATCH] kernel: Don't crash when all windows are closed --- kernel/window/window.asm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/window/window.asm b/kernel/window/window.asm index 1755279..ce15aba 100644 --- a/kernel/window/window.asm +++ b/kernel/window/window.asm @@ -202,6 +202,8 @@ destroy_window: ; set the active window to whatever entry is found first call search_for_nonempty_window_list_entry mov.8 [active_window_offset], r0 + cmp r0, 0xFFFFFFFF + ifz jmp destroy_window_no_more_windows ; set the menu bar for the newly active window call window_list_offset_to_struct @@ -214,6 +216,12 @@ destroy_window: cmp r0, 0 ifnz call draw_menu_bar_root_items + pop r1 + pop r0 + ret +destroy_window_no_more_windows: + call disable_menu_bar + pop r1 pop r0 ret