Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-02-16 04:54:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-16 05:10:32 +0300
commitae375b4cdc737646b770a722c8a47c22f6992dc4 (patch)
tree09d1294e3b8b14fb844cbad9468462ee5bd64a87 /source/blender/makesdna/intern
parent2f737c4f475a5625f9140b84ffd55435ca2fd805 (diff)
DNA: ensure new names exist when renaming
Fail to build on errors in new names - without this renamed values would be written to DNA breaking backwards & forwards compatibility. Note that errors in old names aren't detected.
Diffstat (limited to 'source/blender/makesdna/intern')
-rw-r--r--source/blender/makesdna/intern/dna_rename_defs.h3
-rw-r--r--source/blender/makesdna/intern/makesdna.c20
2 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h
index 62752d6693a..4107797c8a1 100644
--- a/source/blender/makesdna/intern/dna_rename_defs.h
+++ b/source/blender/makesdna/intern/dna_rename_defs.h
@@ -33,6 +33,9 @@
* All references to the previous destination name can be removed since they're
* never written to disk.
*
+ * - Old names aren't sanity checked (since this file is the only place that knows about them)
+ * typos in the old names will break both backwards & forwards compatibility **TAKE CARE**.
+ *
* \see versioning_dna.c for a actual version patching.
*/
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 952318482bb..2a6a4545634 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -1464,3 +1464,23 @@ int main(int argc, char **argv)
/* end of list */
/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/** \name DNA Renaming Sanity Check
+ *
+ * Without this it's possible to reference struct members that don't exist,
+ * breaking backward & forward compatibility.
+ *
+ * \{ */
+
+static void UNUSED_FUNCTION(dna_rename_defs_ensure)(void)
+{
+#define DNA_STRUCT_RENAME(old, new) (void)sizeof(new);
+#define DNA_STRUCT_RENAME_ELEM(struct_name, old, new) (void)offsetof(struct_name, new);
+#include "dna_rename_defs.h"
+#undef DNA_STRUCT_RENAME
+#undef DNA_STRUCT_RENAME_ELEM
+}
+
+/** \} */