diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 104b17961d6..869fef23a55 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1017,7 +1017,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust } } // Check for the existence of a csproj file. - if (_csproj_exists(get_resource_path())) { + if (_csproj_exists(p_path.get_base_dir())) { // If there is a csproj file, add the C# feature if it doesn't already exist. if (!project_features.has("C#")) { project_features.append("C#"); @@ -1568,6 +1568,14 @@ ProjectSettings::ProjectSettings() { ProjectSettings::get_singleton()->add_hidden_prefix("input/"); } -ProjectSettings::~ProjectSettings() { - singleton = nullptr; +ProjectSettings::ProjectSettings(const String &p_path) { + if (load_custom(p_path) == OK) { + project_loaded = true; + } +} + +ProjectSettings::~ProjectSettings() { + if (singleton == this) { + singleton = nullptr; + } } diff --git a/core/config/project_settings.h b/core/config/project_settings.h index 1bad76acb10..922c88c1513 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -224,6 +224,7 @@ public: #endif ProjectSettings(); + ProjectSettings(const String &p_path); ~ProjectSettings(); }; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 70cef0e345a..4fe91d1cc51 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -802,18 +802,20 @@ void ProjectManager::_apply_project_tags() { } } - ConfigFile cfg; const String project_godot = project_list->get_selected_projects()[0].path.path_join("project.godot"); - Error err = cfg.load(project_godot); - if (err != OK) { - tag_edit_error->set_text(vformat(TTR("Couldn't load project at '%s' (error %d). It may be missing or corrupted."), project_godot, err)); + ProjectSettings *cfg = memnew(ProjectSettings(project_godot)); + if (!cfg->is_project_loaded()) { + memdelete(cfg); + tag_edit_error->set_text(vformat(TTR("Couldn't load project at '%s'. It may be missing or corrupted."), project_godot)); tag_edit_error->show(); callable_mp((Window *)tag_manage_dialog, &Window::show).call_deferred(); // Make sure the dialog does not disappear. return; } else { tags.sort(); - cfg.set_value("application", "config/tags", tags); - err = cfg.save(project_godot); + cfg->set("application/config/tags", tags); + Error err = cfg->save_custom(project_godot); + memdelete(cfg); + if (err != OK) { tag_edit_error->set_text(vformat(TTR("Couldn't save project at '%s' (error %d)."), project_godot, err)); tag_edit_error->show();