From 2ae327339b72978ae89aab862f4156f1bc3d49ee Mon Sep 17 00:00:00 2001 From: betalars Date: Sat, 8 Jul 2023 22:06:06 +0200 Subject: [PATCH] fixing error handling when focus list is empty --- src/singletons/global_state.gd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/singletons/global_state.gd b/src/singletons/global_state.gd index 326b7f3..df2991f 100644 --- a/src/singletons/global_state.gd +++ b/src/singletons/global_state.gd @@ -53,10 +53,11 @@ func pass_focus_to(target:Object) -> bool: push_error("Focus instance not valid") elif !"has_focus" in target: push_error(target, " has no has focus method.") - if focus_list.front() == target: - push_warning(target, " is already target. Abort passing focus.") + if focus_list.size() > 0: + if focus_list.front() == target: + push_warning(target, " is already target. Abort passing focus.") else: - if not focus_list.front() == null: focus_list.front().has_focus = false + if not focus_list.size() == 0: focus_list.front().has_focus = false target.has_focus = true if target.has_focus: focus_list.push_front(target)