瀏覽代碼

fix crash after click on MeshInstance with no owner

cherrypicked from #10258
Jakub Grzesik 8 年之前
父節點
當前提交
295e0b6937
共有 1 個文件被更改,包括 5 次插入7 次删除
  1. 5 7
      editor/plugins/spatial_editor_plugin.cpp

+ 5 - 7
editor/plugins/spatial_editor_plugin.cpp

@@ -276,19 +276,19 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
 
 		Ref<SpatialEditorGizmo> seg = spat->get_gizmo();
 
-		if (!seg.is_valid() || found_gizmos.has(seg)){
+		if (!seg.is_valid() || found_gizmos.has(seg)) {
 			Node *subscene_candidate = spat;
-			while (subscene_candidate->get_owner() != editor->get_edited_scene())
+
+			while ((subscene_candidate->get_owner() != NULL) && (subscene_candidate->get_owner() != editor->get_edited_scene()))
 				subscene_candidate = subscene_candidate->get_owner();
 
 			spat = subscene_candidate->cast_to<Spatial>();
-			if (spat && (spat->get_filename() != ""))
+			if (spat && (spat->get_filename() != "") && (subscene_candidate->get_owner() != NULL))
 				subscenes.push_back(spat);
 
 			continue;
 		}
 
-
 		found_gizmos.insert(seg);
 		Vector3 point;
 		Vector3 normal;
@@ -331,7 +331,6 @@ ObjectID SpatialEditorViewport::_select_ray(const Point2 &p_pos, bool p_append,
 		results.push_back(res);
 	}
 
-
 	if (results.empty())
 		return 0;
 
@@ -765,8 +764,7 @@ void SpatialEditorViewport::_list_select(InputEventMouseButton b) {
 			selection_menu->add_item(spat->get_name());
 			selection_menu->set_item_icon(i, icon);
 			selection_menu->set_item_metadata(i, node_path);
-			selection_menu->set_item_tooltip(i, String(spat->get_name()) +
-														"\nType: " + spat->get_type() + "\nPath: " + node_path);
+			selection_menu->set_item_tooltip(i, String(spat->get_name()) + "\nType: " + spat->get_type() + "\nPath: " + node_path);
 		}
 
 		selection_menu->set_global_pos(Vector2(b.global_x, b.global_y));