瀏覽代碼

Check for null pointer in get_column_width(0)

Justin Ho 4 年之前
父節點
當前提交
fa6fd3a2d0
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      scene/gui/tree.cpp

+ 5 - 1
scene/gui/tree.cpp

@@ -3506,9 +3506,13 @@ int Tree::get_column_width(int p_column) const {
 		return columns[p_column].min_width;
 	}
 
+	int expand_area = get_size().width;
+
 	Ref<StyleBox> bg = cache.bg;
 
-	int expand_area = get_size().width - (bg->get_margin(SIDE_LEFT) + bg->get_margin(SIDE_RIGHT));
+	if (bg.is_valid()) {
+		expand_area -= bg->get_margin(SIDE_LEFT) + bg->get_margin(SIDE_RIGHT);
+	}
 
 	if (v_scroll->is_visible_in_tree()) {
 		expand_area -= v_scroll->get_combined_minimum_size().width;