diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-12-05 09:10:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-05 09:10:00 +0100 |
commit | 3a503f62af8a84e0f3aa0e1efc09c490efc56ae3 (patch) | |
tree | 9f83a2fefc8c043a23d355b6c7c3c149cf8ca979 | |
parent | e218dde3f44ccf74f25dbcca99c2c30c8119dc6f (diff) | |
parent | 6af42c536a432ba4228da59876a4b08852a7fa77 (diff) |
Merge pull request #13989 from vnen/gdnative-singleton
GDNative: Save singletons only if there's a change
-rw-r--r-- | modules/gdnative/register_types.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index 34099bf528..365def75bc 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -103,16 +103,34 @@ static void actual_discoverer_handler() { Set<String> file_paths = get_gdnative_singletons(dir); + bool changed = false; + Array current_files = ProjectSettings::get_singleton()->get("gdnative/singletons"); Array files; files.resize(file_paths.size()); int i = 0; for (Set<String>::Element *E = file_paths.front(); E; i++, E = E->next()) { + if (!current_files.has(E->get())) { + changed = true; + } files.set(i, E->get()); } - ProjectSettings::get_singleton()->set("gdnative/singletons", files); + // Check for removed files + if (!changed) { + for (int i = 0; i < current_files.size(); i++) { + if (!file_paths.has(current_files[i])) { + changed = true; + break; + } + } + } - ProjectSettings::get_singleton()->save(); + if (changed) { + + ProjectSettings::get_singleton()->set("gdnative/singletons", files); + + ProjectSettings::get_singleton()->save(); + } } static GDNativeSingletonDiscover *discoverer = NULL; |