瀏覽代碼

Fix Tabs crash where it still tries to detect the clicked tab even if there are none

Robin Arys 4 年之前
父節點
當前提交
2203670ccc
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      scene/gui/tab_bar.cpp

+ 5 - 0
scene/gui/tab_bar.cpp

@@ -222,6 +222,11 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) {
 				}
 			}
 
+			if (max_drawn_tab <= 0) {
+				// Return early if there are no actual tabs to handle input for.
+				return;
+			}
+
 			int found = -1;
 			for (int i = offset; i <= max_drawn_tab; i++) {
 				if (tabs[i].rb_rect.has_point(pos)) {