summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2019-12-05 15:20:50 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2019-12-05 16:19:00 +0800
commite8838f438521113d8c8154a1f707a0b2529f366e (patch)
treeb924daa275e44ff7148bc531ccf948fba1a8338f
parent129a22cd905d1163641a56a956a69747e4e3c17a (diff)
Fixes crash when clearing guides in empty scene
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 9894c8c562..3dffbf5f9b 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -4752,19 +4752,21 @@ void CanvasItemEditor::_popup_callback(int p_op) {
} break;
case CLEAR_GUIDES: {
- if (EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_horizontal_guides_") || EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_vertical_guides_")) {
+ Node *const root = EditorNode::get_singleton()->get_edited_scene();
+
+ if (root && (root->has_meta("_edit_horizontal_guides_") || root->has_meta("_edit_vertical_guides_"))) {
undo_redo->create_action(TTR("Clear Guides"));
- if (EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_horizontal_guides_")) {
- Array hguides = EditorNode::get_singleton()->get_edited_scene()->get_meta("_edit_horizontal_guides_");
+ if (root->has_meta("_edit_horizontal_guides_")) {
+ Array hguides = root->get_meta("_edit_horizontal_guides_");
- undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", Array());
- undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides);
+ undo_redo->add_do_method(root, "set_meta", "_edit_horizontal_guides_", Array());
+ undo_redo->add_undo_method(root, "set_meta", "_edit_horizontal_guides_", hguides);
}
- if (EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_vertical_guides_")) {
- Array vguides = EditorNode::get_singleton()->get_edited_scene()->get_meta("_edit_vertical_guides_");
+ if (root->has_meta("_edit_vertical_guides_")) {
+ Array vguides = root->get_meta("_edit_vertical_guides_");
- undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", Array());
- undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides);
+ undo_redo->add_do_method(root, "set_meta", "_edit_vertical_guides_", Array());
+ undo_redo->add_undo_method(root, "set_meta", "_edit_vertical_guides_", vguides);
}
undo_redo->add_undo_method(viewport, "update");
undo_redo->commit_action();