From 4fef5af95af3a2b9a91b394c610d31aa3b9bceeb Mon Sep 17 00:00:00 2001 From: Lyuma Date: Tue, 13 Aug 2024 17:31:44 -0700 Subject: [PATCH] Avoid [] for external_animation_library import option Some uses of operator[] were causing "rest_pose/external_animation_library": null to be added to the .import file. --- editor/import/3d/resource_importer_scene.cpp | 2 +- editor/import/3d/scene_import_settings.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp index df4026195c25..60acf1f8b237 100644 --- a/editor/import/3d/resource_importer_scene.cpp +++ b/editor/import/3d/resource_importer_scene.cpp @@ -2206,7 +2206,7 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor return false; } } else if (int(p_options["rest_pose/load_pose"]) == 2) { - Object *res = p_options["rest_pose/external_animation_library"]; + Object *res = p_options.get("rest_pose/external_animation_library", Variant()); Ref anim(res); if (anim.is_valid() && p_option == "rest_pose/selected_animation") { return false; diff --git a/editor/import/3d/scene_import_settings.cpp b/editor/import/3d/scene_import_settings.cpp index 6b741b7dd719..60036546b0e0 100644 --- a/editor/import/3d/scene_import_settings.cpp +++ b/editor/import/3d/scene_import_settings.cpp @@ -117,7 +117,9 @@ class SceneImportSettingsData : public Object { ERR_FAIL_NULL(settings); if (r_option.name == "rest_pose/load_pose") { if (!settings->has("rest_pose/load_pose") || int((*settings)["rest_pose/load_pose"]) != 2) { - (*settings)["rest_pose/external_animation_library"] = Variant(); + if (settings->has("rest_pose/external_animation_library")) { + (*settings)["rest_pose/external_animation_library"] = Variant(); + } } } if (r_option.name == "rest_pose/selected_animation") { @@ -134,7 +136,7 @@ class SceneImportSettingsData : public Object { } } break; case 2: { - Object *res = (*settings)["rest_pose/external_animation_library"]; + Object *res = (*settings).get("rest_pose/external_animation_library", Variant()); Ref anim(res); Ref library(res); if (anim.is_valid()) {