GDNative: Save singletons only if there's a change
Ensures that the Project Settings are saved only if the list of singletons actually changed.
This commit is contained in:
parent
055c5600c8
commit
6af42c536a
|
@ -103,17 +103,35 @@ 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());
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
|
||||
ProjectSettings::get_singleton()->set("gdnative/singletons", files);
|
||||
|
||||
ProjectSettings::get_singleton()->save();
|
||||
}
|
||||
}
|
||||
|
||||
static GDNativeSingletonDiscover *discoverer = NULL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue