@@ -5321,7 +5321,7 @@ Ref<GLTFObjectModelProperty> GLTFDocument::import_object_model_property(Ref<GLTF
53215321 // It should check `split.size() > 4 and split[0] == "nodes" and split[2] == "extensions" and split[3] == "MY_ext"`
53225322 // at the start of the function to check if this JSON pointer applies to it, then it can handle `split[4]`.
53235323 if (!ret->has_node_paths ()) {
5324- for (Ref<GLTFDocumentExtension> ext : all_document_extensions ) {
5324+ for (Ref<GLTFDocumentExtension> ext : get_all_gltf_document_extensions () ) {
53255325 ret = ext->import_object_model_property (p_state, split, partial_paths);
53265326 if (ret.is_valid () && ret->has_node_paths ()) {
53275327 if (!ret->has_json_pointers ()) {
@@ -5571,7 +5571,7 @@ Ref<GLTFObjectModelProperty> GLTFDocument::export_object_model_property(Ref<GLTF
55715571 ret->set_json_pointers (split_json_pointers);
55725572 } else {
55735573 // We don't have a mapping, so we need to ask GLTFDocumentExtension classes if they have a mapping.
5574- for (Ref<GLTFDocumentExtension> ext : all_document_extensions ) {
5574+ for (Ref<GLTFDocumentExtension> ext : get_all_gltf_document_extensions () ) {
55755575 ret = ext->export_object_model_property (p_state, p_node_path, p_godot_node, p_gltf_node_index, target_object, target_prop_depth);
55765576 if (ret.is_valid () && ret->has_json_pointers ()) {
55775577 if (!ret->has_node_paths ()) {
@@ -6731,7 +6731,7 @@ Error GLTFDocument::_parse(Ref<GLTFState> p_state, const String &p_path, Ref<Fil
67316731 ERR_FAIL_COND_V (err != OK , err);
67326732
67336733 document_extensions.clear ();
6734- for (Ref<GLTFDocumentExtension> ext : all_document_extensions ) {
6734+ for (Ref<GLTFDocumentExtension> ext : get_all_gltf_document_extensions () ) {
67356735 ERR_CONTINUE (ext.is_null ());
67366736 Ref<GLTFDocumentExtension> ext_dup = ext;
67376737 if (ClassDB::is_class_exposed (ext->get_class_name ())) {
@@ -6962,8 +6962,10 @@ void GLTFDocument::_build_parent_hierarchy(Ref<GLTFState> p_state) {
69626962}
69636963
69646964Vector<Ref<GLTFDocumentExtension>> GLTFDocument::all_document_extensions;
6965+ Mutex GLTFDocument::all_document_extensions_mutex;
69656966
69666967void GLTFDocument::register_gltf_document_extension (Ref<GLTFDocumentExtension> p_extension, bool p_first_priority) {
6968+ MutexLock lock (all_document_extensions_mutex);
69676969 if (!all_document_extensions.has (p_extension)) {
69686970 if (p_first_priority) {
69696971 all_document_extensions.insert (0 , p_extension);
@@ -6974,14 +6976,17 @@ void GLTFDocument::register_gltf_document_extension(Ref<GLTFDocumentExtension> p
69746976}
69756977
69766978void GLTFDocument::unregister_gltf_document_extension (Ref<GLTFDocumentExtension> p_extension) {
6979+ MutexLock lock (all_document_extensions_mutex);
69776980 all_document_extensions.erase (p_extension);
69786981}
69796982
69806983void GLTFDocument::unregister_all_gltf_document_extensions () {
6984+ MutexLock lock (all_document_extensions_mutex);
69816985 all_document_extensions.clear ();
69826986}
69836987
69846988Vector<Ref<GLTFDocumentExtension>> GLTFDocument::get_all_gltf_document_extensions () {
6989+ MutexLock lock (all_document_extensions_mutex);
69856990 return all_document_extensions;
69866991}
69876992
@@ -7007,7 +7012,7 @@ HashSet<String> GLTFDocument::get_supported_gltf_extensions_hashset() {
70077012 supported_extensions.insert (" KHR_materials_unlit" );
70087013 supported_extensions.insert (" KHR_node_visibility" );
70097014 supported_extensions.insert (" KHR_texture_transform" );
7010- for (Ref<GLTFDocumentExtension> ext : all_document_extensions ) {
7015+ for (Ref<GLTFDocumentExtension> ext : get_all_gltf_document_extensions () ) {
70117016 ERR_CONTINUE (ext.is_null ());
70127017 Vector<String> ext_supported_extensions = ext->get_supported_extensions ();
70137018 for (int i = 0 ; i < ext_supported_extensions.size (); ++i) {
@@ -7307,7 +7312,7 @@ Error GLTFDocument::append_from_scene(Node *p_node, Ref<GLTFState> p_state, uint
73077312 // Perform export preflight for document extensions. Only extensions that
73087313 // return OK will be used for the rest of the export steps.
73097314 document_extensions.clear ();
7310- for (Ref<GLTFDocumentExtension> ext : all_document_extensions ) {
7315+ for (Ref<GLTFDocumentExtension> ext : get_all_gltf_document_extensions () ) {
73117316 ERR_CONTINUE (ext.is_null ());
73127317 Ref<GLTFDocumentExtension> ext_dup = ext;
73137318 if (ClassDB::is_class_exposed (ext->get_class_name ())) {
0 commit comments