Merge pull request #7927 from volzhs/wrong-ref-treeitem

Fix wrong TreeItem reference after reconstructing
This commit is contained in:
Rémi Verschelde 2017-03-04 16:48:02 +01:00 committed by GitHub
commit 51f1a56d20
2 changed files with 4 additions and 2 deletions

View File

@ -848,7 +848,6 @@ void Tree::update_cache() {
cache.title_button_color = get_color("title_button_color"); cache.title_button_color = get_color("title_button_color");
v_scroll->set_custom_step(cache.font->get_height()); v_scroll->set_custom_step(cache.font->get_height());
cache.click_item=get_selected();
} }
@ -1611,6 +1610,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
cache.click_id=c.buttons[j].id; cache.click_id=c.buttons[j].id;
cache.click_item=p_item; cache.click_item=p_item;
cache.click_column=col; cache.click_column=col;
cache.click_pos=get_global_mouse_pos()-get_global_pos();
update(); update();
//emit_signal("button_pressed"); //emit_signal("button_pressed");
return -1; return -1;
@ -2391,6 +2391,8 @@ void Tree::_gui_input(InputEvent p_event) {
if (cache.click_type==Cache::CLICK_BUTTON) { if (cache.click_type==Cache::CLICK_BUTTON) {
// make sure in case of wrong reference after reconstructing whole TreeItems
cache.click_item=get_item_at_pos(cache.click_pos);
emit_signal("button_pressed",cache.click_item,cache.click_column,cache.click_id); emit_signal("button_pressed",cache.click_item,cache.click_column,cache.click_id);
} }
@ -2971,7 +2973,6 @@ void Tree::clear() {
selected_item=NULL; selected_item=NULL;
edited_item=NULL; edited_item=NULL;
popup_edited_item=NULL; popup_edited_item=NULL;
selected_item=NULL;
update(); update();
}; };

View File

@ -409,6 +409,7 @@ friend class TreeItem;
TreeItem *click_item; TreeItem *click_item;
int click_column; int click_column;
int hover_index; int hover_index;
Point2 click_pos;
} cache; } cache;