Skip to content

Commit f1c1916

Browse files
committed
Safeguard against freed exported nodes
1 parent 1f56d96 commit f1c1916

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

editor/editor_properties.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,10 +2800,13 @@ void EditorPropertyNodePath::_text_submitted(const String &p_text) {
28002800
}
28012801

28022802
const NodePath EditorPropertyNodePath::_get_node_path() const {
2803-
const Node *base_node = const_cast<EditorPropertyNodePath *>(this)->get_base_node();
2804-
28052803
Variant val = get_edited_property_value();
2806-
Node *n = Object::cast_to<Node>(val);
2804+
if (val.get_type() == Variant::NODE_PATH) {
2805+
return val;
2806+
}
2807+
2808+
const Node *base_node = const_cast<EditorPropertyNodePath *>(this)->get_base_node();
2809+
const Node *n = Object::cast_to<Node>(val.get_validated_object());
28072810
if (n) {
28082811
if (!n->is_inside_tree()) {
28092812
return NodePath();
@@ -2813,9 +2816,8 @@ const NodePath EditorPropertyNodePath::_get_node_path() const {
28132816
} else {
28142817
return get_tree()->get_edited_scene_root()->get_path_to(n);
28152818
}
2816-
} else {
2817-
return val;
28182819
}
2820+
return NodePath();
28192821
}
28202822

28212823
bool EditorPropertyNodePath::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {

0 commit comments

Comments
 (0)