summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-04-25 17:12:38 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-04-25 17:12:38 +0200
commitf859400c6b55d802c3102a098dc32c0a902ba6e5 (patch)
treef7febaf18521a58b9da93f312d1973c25c0725e6
parent5a14db7554283fbf228cd9d427bc708b1faa9477 (diff)
parente63d0983d0245db11ca513ecfc0a4309fef57543 (diff)
downloadredot-engine-f859400c6b55d802c3102a098dc32c0a902ba6e5.tar.gz
Merge pull request #91078 from aaronp64/import_skip_crash
Fix errors/crashes related to skipped imports
-rw-r--r--editor/import_dock.cpp24
-rw-r--r--editor/import_dock.h1
-rw-r--r--modules/gltf/editor/editor_scene_importer_blend.cpp1
3 files changed, 22 insertions, 4 deletions
diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp
index 6f4a376496..fa503cc4df 100644
--- a/editor/import_dock.cpp
+++ b/editor/import_dock.cpp
@@ -200,7 +200,8 @@ void ImportDock::_update_options(const String &p_path, const Ref<ConfigFile> &p_
params->update();
_update_preset_menu();
- if (params->importer.is_valid() && params->paths.size() == 1 && params->importer->has_advanced_options()) {
+ bool was_imported = p_config.is_valid() && p_config->get_value("remap", "importer") != "skip" && p_config->get_value("remap", "importer") != "keep";
+ if (was_imported && params->importer.is_valid() && params->paths.size() == 1 && params->importer->has_advanced_options()) {
advanced->show();
advanced_spacer->show();
} else {
@@ -508,6 +509,18 @@ static bool _find_owners(EditorFileSystemDirectory *efsd, const String &p_path)
return false;
}
+void ImportDock::_reimport_pressed() {
+ _reimport_attempt();
+
+ if (params->importer.is_valid() && params->paths.size() == 1 && params->importer->has_advanced_options()) {
+ advanced->show();
+ advanced_spacer->show();
+ } else {
+ advanced->hide();
+ advanced_spacer->hide();
+ }
+}
+
void ImportDock::_reimport_attempt() {
bool used_in_resources = false;
@@ -528,7 +541,7 @@ void ImportDock::_reimport_attempt() {
ERR_CONTINUE(err != OK);
String imported_with = config->get_value("remap", "importer");
- if (imported_with != importer_name) {
+ if (imported_with != importer_name && imported_with != "keep" && imported_with != "skip") {
Ref<Resource> resource = ResourceLoader::load(params->paths[i]);
if (resource.is_valid()) {
need_cleanup.push_back(params->paths[i]);
@@ -575,7 +588,10 @@ void ImportDock::_reimport_and_cleanup() {
for (const String &path : need_cleanup) {
Ref<Resource> old_res = old_resources[path];
- Ref<Resource> new_res = ResourceLoader::load(path);
+ Ref<Resource> new_res;
+ if (params->importer.is_valid()) {
+ new_res = ResourceLoader::load(path);
+ }
for (int i = 0; i < EditorNode::get_editor_data().get_edited_scene_count(); i++) {
Node *edited_scene_root = EditorNode::get_editor_data().get_edited_scene_root(i);
@@ -782,7 +798,7 @@ ImportDock::ImportDock() {
import = memnew(Button);
import->set_text(TTR("Reimport"));
import->set_disabled(true);
- import->connect("pressed", callable_mp(this, &ImportDock::_reimport_attempt));
+ import->connect("pressed", callable_mp(this, &ImportDock::_reimport_pressed));
if (!DisplayServer::get_singleton()->get_swap_cancel_ok()) {
advanced_spacer = hb->add_spacer();
advanced = memnew(Button);
diff --git a/editor/import_dock.h b/editor/import_dock.h
index 78cd6a556c..c0a1dee7ca 100644
--- a/editor/import_dock.h
+++ b/editor/import_dock.h
@@ -76,6 +76,7 @@ class ImportDock : public VBoxContainer {
void _property_edited(const StringName &p_prop);
void _property_toggled(const StringName &p_prop, bool p_checked);
void _set_dirty(bool p_dirty);
+ void _reimport_pressed();
void _reimport_attempt();
void _reimport_and_cleanup();
void _reimport();
diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp
index abc89e4e97..42c3ecc7cb 100644
--- a/modules/gltf/editor/editor_scene_importer_blend.cpp
+++ b/modules/gltf/editor/editor_scene_importer_blend.cpp
@@ -298,6 +298,7 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_
}
return nullptr;
}
+ ERR_FAIL_COND_V(!p_options.has("animation/fps"), nullptr);
#ifndef DISABLE_DEPRECATED
bool trimming = p_options.has("animation/trimming") ? (bool)p_options["animation/trimming"] : false;