1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Fix crash on wrong type drag into the vs editor

Don't allow drops of draggable items without a vs node type.

This fixes #10935
This commit is contained in:
Hein-Pieter van Braam
2017-09-09 00:24:54 +02:00
parent d1cb73b47a
commit 2ec0bc4f80

View File

@@ -1495,10 +1495,20 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
if (p_from == graph) { if (p_from != graph) {
return;
}
Dictionary d = p_data; Dictionary d = p_data;
if (d.has("type") && String(d["type"]) == "visual_script_node_drag") {
if (!d.has("type")) {
return;
}
if (String(d["type"]) == "visual_script_node_drag") {
if (!d.has("node_type") || String(d["node_type"]) == "Null") {
return;
}
Vector2 ofs = graph->get_scroll_ofs() + p_point; Vector2 ofs = graph->get_scroll_ofs() + p_point;
@@ -1526,7 +1536,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
} }
} }
if (d.has("type") && String(d["type"]) == "visual_script_variable_drag") { if (String(d["type"]) == "visual_script_variable_drag") {
#ifdef OSX_ENABLED #ifdef OSX_ENABLED
bool use_set = Input::get_singleton()->is_key_pressed(KEY_META); bool use_set = Input::get_singleton()->is_key_pressed(KEY_META);
@@ -1571,7 +1581,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
} }
} }
if (d.has("type") && String(d["type"]) == "visual_script_function_drag") { if (String(d["type"]) == "visual_script_function_drag") {
Vector2 ofs = graph->get_scroll_ofs() + p_point; Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) { if (graph->is_using_snap()) {
@@ -1604,7 +1614,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
} }
} }
if (d.has("type") && String(d["type"]) == "visual_script_signal_drag") { if (String(d["type"]) == "visual_script_signal_drag") {
Vector2 ofs = graph->get_scroll_ofs() + p_point; Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) { if (graph->is_using_snap()) {
@@ -1634,7 +1644,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
} }
} }
if (d.has("type") && String(d["type"]) == "resource") { if (String(d["type"]) == "resource") {
Vector2 ofs = graph->get_scroll_ofs() + p_point; Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) { if (graph->is_using_snap()) {
@@ -1664,7 +1674,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
} }
} }
if (d.has("type") && String(d["type"]) == "files") { if (String(d["type"]) == "files") {
Vector2 ofs = graph->get_scroll_ofs() + p_point; Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) { if (graph->is_using_snap()) {
@@ -1714,7 +1724,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
} }
} }
if (d.has("type") && String(d["type"]) == "nodes") { if (String(d["type"]) == "nodes") {
Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script); Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
@@ -1785,7 +1795,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
undo_redo->commit_action(); undo_redo->commit_action();
} }
if (d.has("type") && String(d["type"]) == "obj_property") { if (String(d["type"]) == "obj_property") {
Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script); Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
@@ -1905,7 +1915,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
undo_redo->commit_action(); undo_redo->commit_action();
} }
} }
}
} }
void VisualScriptEditor::_selected_method(const String &p_method) { void VisualScriptEditor::_selected_method(const String &p_method) {