diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-02-16 00:51:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-02-16 00:51:00 +0300 |
commit | bc657ef16eed438a1eb5156e5b46173044905dcc (patch) | |
tree | dc27eb95de1bdc4140c80bf171abe5186f1971d6 /source | |
parent | eff3728db912abc1477d0e90d2a6533b61f7295f (diff) |
DNA: warn about old versioning being incomplete
Also sync variable names w/ D4342
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesdna/intern/dna_genfile.c | 10 | ||||
-rw-r--r-- | source/blender/makesdna/intern/dna_utils.c | 32 |
2 files changed, 26 insertions, 16 deletions
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 6fb9408c197..cef152fb45d 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -379,6 +379,14 @@ static bool init_structDNA( for (int nr = 0; nr < sdna->nr_types; nr++) { sdna->types[nr] = cp; + /* ------------------------------------------------------------- */ + /* WARNING! + * + * The renaming here isn't complete, references to the old struct names + * are still included in DNA, now fixing these struct names properly + * breaks forward compatibility. Leave these as-is, but don't add to them! + * See D4342#98780 */ + /* this is a patch, to change struct names without a conflict with SDNA */ /* be careful to use it, in this case for a system-struct (opengl/X) */ @@ -394,6 +402,8 @@ static bool init_structDNA( else if (strcmp("CollectionObject", cp) == 0) { sdna->types[nr] = "GroupObject"; } + /* END WARNING */ + /* ------------------------------------------------------------- */ while (*cp) cp++; cp++; diff --git a/source/blender/makesdna/intern/dna_utils.c b/source/blender/makesdna/intern/dna_utils.c index 7065e1a672f..44ad13dc669 100644 --- a/source/blender/makesdna/intern/dna_utils.c +++ b/source/blender/makesdna/intern/dna_utils.c @@ -156,32 +156,32 @@ char *DNA_elem_id_rename( struct MemArena *mem_arena, const char *elem_src, const int elem_src_len, const char *elem_dst, const int elem_dst_len, - const char *elem_full_src, const int elem_full_src_len, - const uint elem_full_offset_start) + const char *elem_src_full, const int elem_src_full_len, + const uint elem_src_full_offset_len) { BLI_assert(strlen(elem_src) == elem_src_len); BLI_assert(strlen(elem_dst) == elem_dst_len); - BLI_assert(strlen(elem_full_src) == elem_full_src_len); - BLI_assert(DNA_elem_id_offset_start(elem_full_src) == elem_full_offset_start); + BLI_assert(strlen(elem_src_full) == elem_src_full_len); + BLI_assert(DNA_elem_id_offset_start(elem_src_full) == elem_src_full_offset_len); UNUSED_VARS_NDEBUG(elem_src); - const int elem_final_len = (elem_full_src_len - elem_src_len) + elem_dst_len; - char *elem_full_dst = BLI_memarena_alloc(mem_arena, elem_final_len + 1); + const int elem_final_len = (elem_src_full_len - elem_src_len) + elem_dst_len; + char *elem_dst_full = BLI_memarena_alloc(mem_arena, elem_final_len + 1); uint i = 0; - if (elem_full_offset_start != 0) { - memcpy(elem_full_dst, elem_full_src, elem_full_offset_start); - i = elem_full_offset_start; + if (elem_src_full_offset_len != 0) { + memcpy(elem_dst_full, elem_src_full, elem_src_full_offset_len); + i = elem_src_full_offset_len; } - memcpy(&elem_full_dst[i], elem_dst, elem_dst_len + 1); + memcpy(&elem_dst_full[i], elem_dst, elem_dst_len + 1); i += elem_dst_len; - uint elem_full_offset_end = elem_full_offset_start + elem_src_len; - if (elem_full_src[elem_full_offset_end] != '\0') { - const int elem_full_tail_len = (elem_full_src_len - elem_full_offset_end); - memcpy(&elem_full_dst[i], &elem_full_src[elem_full_offset_end], elem_full_tail_len + 1); + uint elem_src_full_offset_end = elem_src_full_offset_len + elem_src_len; + if (elem_src_full[elem_src_full_offset_end] != '\0') { + const int elem_full_tail_len = (elem_src_full_len - elem_src_full_offset_end); + memcpy(&elem_dst_full[i], &elem_src_full[elem_src_full_offset_end], elem_full_tail_len + 1); i += elem_full_tail_len; } - BLI_assert((strlen(elem_full_dst) == elem_final_len) && (i == elem_final_len)); - return elem_full_dst; + BLI_assert((strlen(elem_dst_full) == elem_final_len) && (i == elem_final_len)); + return elem_dst_full; } /** \} */ |