Ensure proper config version when reading the new configuration file.
This commit is contained in:
parent
102b5fce85
commit
af3fabeb77
|
@ -38,6 +38,8 @@
|
||||||
#include "io/file_access_network.h"
|
#include "io/file_access_network.h"
|
||||||
#include "variant_parser.h"
|
#include "variant_parser.h"
|
||||||
|
|
||||||
|
#define FORMAT_VERSION 3
|
||||||
|
|
||||||
GlobalConfig *GlobalConfig::singleton=NULL;
|
GlobalConfig *GlobalConfig::singleton=NULL;
|
||||||
|
|
||||||
GlobalConfig *GlobalConfig::get_singleton() {
|
GlobalConfig *GlobalConfig::get_singleton() {
|
||||||
|
@ -491,6 +493,14 @@ Error GlobalConfig::_load_settings(const String p_path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assign!=String()) {
|
if (assign!=String()) {
|
||||||
|
if (section==String() && assign=="config_version") {
|
||||||
|
int config_version = value;
|
||||||
|
if (config_version > FORMAT_VERSION) {
|
||||||
|
memdelete(f);
|
||||||
|
ERR_FAIL_COND_V(config_version > FORMAT_VERSION,ERR_FILE_CANT_OPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
set(section+"/"+assign,value);
|
set(section+"/"+assign,value);
|
||||||
} else if (next_tag.name!=String()) {
|
} else if (next_tag.name!=String()) {
|
||||||
section=next_tag.name;
|
section=next_tag.name;
|
||||||
|
@ -608,6 +618,9 @@ Error GlobalConfig::_save_settings_text(const String& p_file,const Map<String,Li
|
||||||
ERR_FAIL_COND_V(err,err)
|
ERR_FAIL_COND_V(err,err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file->store_string("config_version="+itos(FORMAT_VERSION)+"\n");
|
||||||
|
|
||||||
|
|
||||||
for(Map<String,List<String> >::Element *E=props.front();E;E=E->next()) {
|
for(Map<String,List<String> >::Element *E=props.front();E;E=E->next()) {
|
||||||
|
|
||||||
if (E!=props.front())
|
if (E!=props.front())
|
||||||
|
|
|
@ -544,7 +544,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess
|
||||||
if (f.begins_with(".")) //ignore hidden and . / ..
|
if (f.begins_with(".")) //ignore hidden and . / ..
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (FileAccess::exists(cd.plus_file(f).plus_file("engine.cfg"))) // skip if another project inside this
|
if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dirs.push_back(f);
|
dirs.push_back(f);
|
||||||
|
@ -733,7 +733,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir,const S
|
||||||
int idx = p_dir->find_dir_index(f);
|
int idx = p_dir->find_dir_index(f);
|
||||||
if (idx==-1) {
|
if (idx==-1) {
|
||||||
|
|
||||||
if (FileAccess::exists(cd.plus_file(f).plus_file("engine.cfg"))) // skip if another project inside this
|
if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory );
|
EditorFileSystemDirectory *efd = memnew( EditorFileSystemDirectory );
|
||||||
|
|
Loading…
Reference in New Issue