From 2dc9cf50c5d5be344498deb7b5472c3c7212a339 Mon Sep 17 00:00:00 2001 From: Hilderin <81109165+Hilderin@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:20:41 -0400 Subject: [PATCH] Fix no validation on Blender path on importation --- modules/gltf/editor/editor_scene_importer_blend.cpp | 11 +++++++++-- modules/gltf/editor/editor_scene_importer_blend.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index ec3ea9bcae4..0b8fb584df2 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -115,8 +115,15 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_ List *r_missing_deps, Error *r_err) { String blender_path = EDITOR_GET("filesystem/import/blender/blender_path"); - if (blender_major_version == -1 || blender_minor_version == -1) { - _get_blender_version(blender_path, blender_major_version, blender_minor_version, nullptr); + ERR_FAIL_COND_V_MSG(blender_path.is_empty(), nullptr, "Blender path is empty, check your Editor Settings."); + ERR_FAIL_COND_V_MSG(!FileAccess::exists(blender_path), nullptr, vformat("Invalid Blender path: %s, check your Editor Settings.", blender_path)); + + if (blender_major_version == -1 || blender_minor_version == -1 || last_tested_blender_path != blender_path) { + String error; + if (!_get_blender_version(blender_path, blender_major_version, blender_minor_version, &error)) { + ERR_FAIL_V_MSG(nullptr, error); + } + last_tested_blender_path = blender_path; } // Get global paths for source and sink. diff --git a/modules/gltf/editor/editor_scene_importer_blend.h b/modules/gltf/editor/editor_scene_importer_blend.h index 8a6c65a6248..6adace92763 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.h +++ b/modules/gltf/editor/editor_scene_importer_blend.h @@ -45,6 +45,7 @@ class EditorSceneFormatImporterBlend : public EditorSceneFormatImporter { int blender_major_version = -1; int blender_minor_version = -1; + String last_tested_blender_path; public: enum {