diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-31 13:20:04 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-31 13:20:04 +0100 |
commit | e1648b3327431a09cc9498663fac483275eb711d (patch) | |
tree | 820eef8ec10cdfa1b5a0478ed9813ea25d600c33 /core | |
parent | e768e02b789d2d0afbbc4f775d8cd8e807b1d79c (diff) | |
parent | 79897dd5bc75bb0553a48fd36537454f5ad95764 (diff) |
Merge pull request #72445 from reduz/restore-script-class-cache-if-removed
Restore script class cache if removed
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 8 | ||||
-rw-r--r-- | core/config/project_settings.h | 1 | ||||
-rw-r--r-- | core/object/script_language.cpp | 8 | ||||
-rw-r--r-- | core/object/script_language.h | 2 |
4 files changed, 17 insertions, 2 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 00e74a7cce..b63fbde7a0 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1137,7 +1137,7 @@ Array ProjectSettings::get_global_class_list() { Ref<ConfigFile> cf; cf.instantiate(); - if (cf->load(get_project_data_path().path_join("global_script_class_cache.cfg")) == OK) { + if (cf->load(get_global_class_list_path()) == OK) { script_classes = cf->get_value("", "list"); } else { #ifndef TOOLS_ENABLED @@ -1148,11 +1148,15 @@ Array ProjectSettings::get_global_class_list() { return script_classes; } +String ProjectSettings::get_global_class_list_path() const { + return get_project_data_path().path_join("global_script_class_cache.cfg"); +} + void ProjectSettings::store_global_class_list(const Array &p_classes) { Ref<ConfigFile> cf; cf.instantiate(); cf->set_value("", "list", p_classes); - cf->save(get_project_data_path().path_join("global_script_class_cache.cfg")); + cf->save(get_global_class_list_path()); } bool ProjectSettings::has_custom_feature(const String &p_feature) const { diff --git a/core/config/project_settings.h b/core/config/project_settings.h index d1704a7c31..70f697741f 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -143,6 +143,7 @@ public: Variant get_setting(const String &p_setting, const Variant &p_default_value = Variant()) const; Array get_global_class_list(); void store_global_class_list(const Array &p_classes); + String get_global_class_list_path() const; bool has_setting(String p_var) const; String localize_path(const String &p_path) const; diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index df5486512d..61f5cfc22a 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -369,6 +369,14 @@ void ScriptServer::save_global_classes() { ProjectSettings::get_singleton()->store_global_class_list(gcarr); } +bool ScriptServer::has_global_classes() { + return !global_classes.is_empty(); +} + +String ScriptServer::get_global_class_cache_file_path() { + return ProjectSettings::get_singleton()->get_global_class_list_path(); +} + //////////////////// Variant ScriptInstance::call_const(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { diff --git a/core/object/script_language.h b/core/object/script_language.h index f82b58439f..b1393c7196 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -91,6 +91,8 @@ public: static void get_global_class_list(List<StringName> *r_global_classes); static void get_inheriters_list(const StringName &p_base_type, List<StringName> *r_classes); static void save_global_classes(); + static bool has_global_classes(); + static String get_global_class_cache_file_path(); static void init_languages(); static void finish_languages(); |