Browse Source

Merge pull request #96372 from CreatedBySeb/fix-signal-copying

Fix copying a Node with a signal potentially resulting in an Editor crash
Thaddeus Crews 5 tháng trước cách đây
mục cha
commit
7d677fe761

+ 7 - 1
editor/connections_dialog.cpp

@@ -453,7 +453,13 @@ void ConnectDialog::_update_ok_enabled() {
 }
 }
 
 
 void ConnectDialog::_update_warning_label() {
 void ConnectDialog::_update_warning_label() {
-	Ref<Script> scr = source->get_node(dst_path)->get_script();
+	Node *dst = source->get_node(dst_path);
+	if (dst == nullptr) {
+		warning_label->set_visible(false);
+		return;
+	}
+
+	Ref<Script> scr = dst->get_script();
 	if (scr.is_null()) {
 	if (scr.is_null()) {
 		warning_label->set_visible(false);
 		warning_label->set_visible(false);
 		return;
 		return;

+ 4 - 0
scene/main/node.cpp

@@ -3063,7 +3063,11 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
 				if (!target) {
 				if (!target) {
 					continue;
 					continue;
 				}
 				}
+
 				NodePath ptarget = p_original->get_path_to(target);
 				NodePath ptarget = p_original->get_path_to(target);
+				if (ptarget.is_empty()) {
+					continue;
+				}
 
 
 				Node *copytarget = target;
 				Node *copytarget = target;