Fix crashes when manipulating nodes in editor
(cherry picked from commit f81ecb498b
)
This commit is contained in:
parent
f8ee8b1b73
commit
1435e2c0f9
1 changed files with 38 additions and 30 deletions
|
@ -924,12 +924,14 @@ void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_it
|
|||
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = E->get();
|
||||
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
|
||||
if (se) {
|
||||
canvas_item->_edit_set_state(se->undo_state);
|
||||
if (restore_bones) {
|
||||
_restore_canvas_item_ik_chain(canvas_item, &(se->pre_drag_bones_undo_state));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_items, String action_name, bool commit_bones) {
|
||||
List<CanvasItem *> modified_canvas_items;
|
||||
|
@ -951,6 +953,7 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite
|
|||
for (List<CanvasItem *>::Element *E = modified_canvas_items.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = E->get();
|
||||
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
|
||||
if (se) {
|
||||
undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state());
|
||||
undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state);
|
||||
if (commit_bones) {
|
||||
|
@ -961,6 +964,7 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
undo_redo->add_do_method(viewport, "update");
|
||||
undo_redo->add_undo_method(viewport, "update");
|
||||
undo_redo->commit_action();
|
||||
|
@ -2126,6 +2130,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
|||
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = E->get();
|
||||
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
|
||||
if (se) {
|
||||
Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform();
|
||||
|
||||
Node2D *node2d = Object::cast_to<Node2D>(canvas_item);
|
||||
|
@ -2138,6 +2143,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
|||
} else {
|
||||
canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos));
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return true;
|
||||
|
@ -2258,6 +2264,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
|||
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
|
||||
CanvasItem *canvas_item = E->get();
|
||||
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
|
||||
if (se) {
|
||||
Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform();
|
||||
|
||||
Node2D *node2d = Object::cast_to<Node2D>(canvas_item);
|
||||
|
@ -2270,6 +2277,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
|||
} else {
|
||||
canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos));
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue