浏览代码

resource: update data versions after full compilation is done

Daniele Bartolini 5 年之前
父节点
当前提交
c03a7cce12
共有 2 个文件被更改,包括 13 次插入1 次删除
  1. 1 0
      docs/changelog.rst
  2. 12 1
      src/resource/data_compiler.cpp

+ 1 - 0
docs/changelog.rst

@@ -7,6 +7,7 @@ Changelog
 
 **Data Compiler**
 
+* Fixed an issue that caused resources to not be compiled with the proper version in rare circumnstances
 * Fixed an issue that caused the compiler to crash when reading empty source files
 * Fixed an issue that prevented the output from external data compilers to not be read under Windows
 

+ 12 - 1
src/resource/data_compiler.cpp

@@ -1091,7 +1091,6 @@ bool DataCompiler::compile(const char* data_dir, const char* platform)
 			if (!path_is_special(path.c_str()))
 			{
 				hash_map::set(_data_index, id, path);
-				hash_map::set(_data_versions, type_str, rtd.version);
 				hash_map::set(_data_mtimes, id, data_fs.last_modified_time(dest.c_str()));
 				hash_map::set(_data_revisions, id, _revision + 1);
 			}
@@ -1105,6 +1104,18 @@ bool DataCompiler::compile(const char* data_dir, const char* platform)
 
 	if (success)
 	{
+		// Data versions are stored per-type, so, before updating _data_versions, we
+		// need to make sure *all* resource files with that type have been
+		// successfully compiled.
+		auto cur = hash_map::begin(_compilers);
+		auto end = hash_map::end(_compilers);
+		for (; cur != end; ++cur)
+		{
+			HASH_MAP_SKIP_HOLE(_compilers, cur);
+
+			hash_map::set(_data_versions, cur->first, cur->second.version);
+		}
+
 		if (vector::size(to_compile))
 		{
 			_revision++;