diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-01-06 19:56:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-06 19:56:29 +0100 |
commit | b6989d0b511ef4003d33f5987a5dafc45cb3a1cf (patch) | |
tree | 79722aebc89800306995013f4394b19eb57d5619 /scene | |
parent | b77c6d43a86d67915999f4f542756dbee90feef8 (diff) | |
parent | 4cbe726cf5b55362d2746ad44abefbe2669ea5b3 (diff) |
Merge pull request #15412 from poke1024/fix-tree-get-rect-crash
Fix crash when calling tree API before NOTIFICATION_ENTER_TREE
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/tree.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 0dffc4ee9a..fd5a47d875 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -916,6 +916,7 @@ int Tree::compute_item_height(TreeItem *p_item) const { if (p_item == root && hide_root) return 0; + ERR_FAIL_COND_V(cache.font.is_null(), 0); int height = cache.font->get_height(); for (int i = 0; i < columns.size(); i++) { @@ -989,6 +990,8 @@ int Tree::get_item_height(TreeItem *p_item) const { void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color) { + ERR_FAIL_COND(cache.font.is_null()); + Rect2i rect = p_rect; Ref<Font> font = cache.font; String text = p_cell.text; @@ -1058,6 +1061,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 //draw separation. //if (p_item->get_parent()!=root || !hide_root) + ERR_FAIL_COND_V(cache.font.is_null(), -1); Ref<Font> font = cache.font; int font_ascent = font->get_ascent(); @@ -2794,6 +2798,7 @@ void Tree::update_scrollbars() { int Tree::_get_title_button_height() const { + ERR_FAIL_COND_V(cache.font.is_null() || cache.title_button.is_null(), 0); return show_column_titles ? cache.font->get_height() + cache.title_button->get_minimum_size().height : 0; } |