Merge pull request #2447 from TheHX/issue_1275

Fix crash after undo when editing Polygon2D (#1275)
This commit is contained in:
Juan Linietsky 2015-11-19 00:21:46 -03:00
commit 2dac9ab2ef
1 changed files with 6 additions and 5 deletions

View File

@ -54,6 +54,8 @@ void Polygon2DEditor::_notification(int p_what) {
b_snap_enable->set_icon( get_icon("Snap", "EditorIcons"));
uv_icon_zoom->set_texture( get_icon("Zoom", "EditorIcons"));
get_tree()->connect("node_removed", this, "_node_removed");
} break;
case NOTIFICATION_FIXED_PROCESS: {
@ -65,8 +67,10 @@ void Polygon2DEditor::_notification(int p_what) {
void Polygon2DEditor::_node_removed(Node *p_node) {
if(p_node==node) {
node=NULL;
edit(NULL);
hide();
canvas_item_editor->get_viewport_control()->update();
}
}
@ -757,16 +761,13 @@ void Polygon2DEditor::edit(Node *p_collision_polygon) {
node=p_collision_polygon->cast_to<Polygon2D>();
if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw");
node->connect("exit_tree",this,"_node_removed",varray(),CONNECT_ONESHOT);
wip.clear();
wip_active=false;
edited_point=-1;
} else {
if (node)
node->disconnect("exit_tree",this,"_node_removed");
node=NULL;
if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))