浏览代码

Fix possible crash when calling Tree.notification from _ready

Robin Arys 3 年之前
父节点
当前提交
5c25497aa2
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      scene/gui/tree.cpp

+ 3 - 1
scene/gui/tree.cpp

@@ -3570,7 +3570,9 @@ int Tree::_get_title_button_height() const {
 
 void Tree::_notification(int p_what) {
 	if (p_what == NOTIFICATION_FOCUS_ENTER) {
-		focus_in_id = get_viewport()->get_processed_events_count();
+		if (get_viewport()) {
+			focus_in_id = get_viewport()->get_processed_events_count();
+		}
 	}
 	if (p_what == NOTIFICATION_MOUSE_EXIT) {
 		if (cache.hover_type != Cache::CLICK_NONE) {