Merge pull request #46759 from qarmin/crashes_others
Fix crashes when manipulating nodes in editor
This commit is contained in:
commit
0bef220f0a
1 changed files with 38 additions and 30 deletions
|
@ -955,11 +955,13 @@ void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_it
|
||||||
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
|
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
|
||||||
CanvasItem *canvas_item = E->get();
|
CanvasItem *canvas_item = E->get();
|
||||||
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
|
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
|
||||||
|
if (se) {
|
||||||
canvas_item->_edit_set_state(se->undo_state);
|
canvas_item->_edit_set_state(se->undo_state);
|
||||||
if (restore_bones) {
|
if (restore_bones) {
|
||||||
_restore_canvas_item_ik_chain(canvas_item, &(se->pre_drag_bones_undo_state));
|
_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) {
|
void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_items, String action_name, bool commit_bones) {
|
||||||
|
@ -982,6 +984,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()) {
|
for (List<CanvasItem *>::Element *E = modified_canvas_items.front(); E; E = E->next()) {
|
||||||
CanvasItem *canvas_item = E->get();
|
CanvasItem *canvas_item = E->get();
|
||||||
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
|
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_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);
|
undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state);
|
||||||
if (commit_bones) {
|
if (commit_bones) {
|
||||||
|
@ -992,6 +995,7 @@ void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_ite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
undo_redo->add_do_method(viewport, "update");
|
undo_redo->add_do_method(viewport, "update");
|
||||||
undo_redo->add_undo_method(viewport, "update");
|
undo_redo->add_undo_method(viewport, "update");
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
|
@ -2238,6 +2242,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
||||||
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
|
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
|
||||||
CanvasItem *canvas_item = E->get();
|
CanvasItem *canvas_item = E->get();
|
||||||
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
|
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();
|
Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform();
|
||||||
|
|
||||||
Node2D *node2d = Object::cast_to<Node2D>(canvas_item);
|
Node2D *node2d = Object::cast_to<Node2D>(canvas_item);
|
||||||
|
@ -2250,6 +2255,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
||||||
} else {
|
} else {
|
||||||
canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos));
|
canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -2372,6 +2378,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
||||||
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
|
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
|
||||||
CanvasItem *canvas_item = E->get();
|
CanvasItem *canvas_item = E->get();
|
||||||
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
|
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();
|
Transform2D xform = canvas_item->get_global_transform_with_canvas().affine_inverse() * canvas_item->get_transform();
|
||||||
|
|
||||||
Node2D *node2d = Object::cast_to<Node2D>(canvas_item);
|
Node2D *node2d = Object::cast_to<Node2D>(canvas_item);
|
||||||
|
@ -2384,6 +2391,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
|
||||||
} else {
|
} else {
|
||||||
canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos));
|
canvas_item->_edit_set_position(canvas_item->_edit_get_position() + xform.xform(new_pos) - xform.xform(previous_pos));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue