Parcourir la 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 il y a 4 mois
Parent
commit
7d677fe761
2 fichiers modifiés avec 11 ajouts et 1 suppressions
  1. 7 1
      editor/connections_dialog.cpp
  2. 4 0
      scene/main/node.cpp

+ 7 - 1
editor/connections_dialog.cpp

@@ -453,7 +453,13 @@ void ConnectDialog::_update_ok_enabled() {
 }
 
 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()) {
 		warning_label->set_visible(false);
 		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) {
 					continue;
 				}
+
 				NodePath ptarget = p_original->get_path_to(target);
+				if (ptarget.is_empty()) {
+					continue;
+				}
 
 				Node *copytarget = target;