diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-12-22 04:24:29 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-12-22 04:25:27 +0300 |
commit | fec3be6b5455c8847df0910f1086be4bdcab8dc1 (patch) | |
tree | ce407f531987b983ba5d3a322981b93246b4b43d /source/blender/blenloader | |
parent | d2ea9c20635e090edbe96d26a1a40ef8b42418a7 (diff) |
T53610: Crash opening file with linked particles
I could done a subversion bump, but I found a safe way to avoid it.
It leads a bit of an ugly code, but once we bump the subversion
next time we can clean it up easily.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 547ae6709b2..ba5beb7993d 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -603,6 +603,38 @@ void do_versions_after_linking_280(Main *main) } } } + + { + for (Object *object = main->object.first; object; object = object->id.next) { +#ifndef VERSION_280_SUBVERSION_4 + /* If any object already has an initialized value for + * duplicator_visibility_flag it means we've already doversioned it. + * TODO(all) remove the VERSION_280_SUBVERSION_4 code once the subversion was bumped. */ + if (object->duplicator_visibility_flag != 0) { + break; + } +#endif + if (object->particlesystem.first) { + object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT; + for (ParticleSystem *psys = object->particlesystem.first; psys; psys=psys->next) { + if (psys->part->draw & PART_DRAW_EMITTER) { + object->duplicator_visibility_flag |= OB_DUPLI_FLAG_RENDER; +#ifndef VERSION_280_SUBVERSION_4 + psys->part->draw &= ~PART_DRAW_EMITTER; +#else + break; +#endif + } + } + } + else if (object->transflag & OB_DUPLI){ + object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT; + } + else { + object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT | OB_DUPLI_FLAG_RENDER; + } + } + } } static void do_version_layer_collections_idproperties(ListBase *lb) @@ -856,28 +888,4 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main) } } } - - { - if (!DNA_struct_elem_find(fd->filesdna, "Object", "char", "duplicator_visibility_flag")) { - for (Object *object = main->object.first; object; object = object->id.next) { - if (object->particlesystem.first) { - bool show_emitter = false; - for (ParticleSystem *psys = object->particlesystem.first; psys; psys=psys->next) { - show_emitter |= (psys->part->draw & PART_DRAW_EMITTER) != 0; - } - - object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT; - if (show_emitter) { - object->duplicator_visibility_flag |= OB_DUPLI_FLAG_RENDER; - } - } - else if (object->transflag & OB_DUPLI){ - object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT; - } - else { - object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT | OB_DUPLI_FLAG_RENDER; - } - } - } - } } |