[Bf-blender-cvs] [ba85b4e45cb] master: Fix: create shallow copy of CustomData before writing

Jacques Lucke noreply at git.blender.org
Wed Sep 16 10:39:14 CEST 2020


Commit: ba85b4e45cbb91d908478975071356fe44a7711b
Author: Jacques Lucke
Date:   Wed Sep 16 10:38:51 2020 +0200
Branches: master
https://developer.blender.org/rBba85b4e45cbb91d908478975071356fe44a7711b

Fix: create shallow copy of CustomData before writing

CustomData_blend_write_prepare might modify the `CustomData`
instance, making it invalid afterwards. It is not necessary to do this
in other cases explicitly, because when writing shallow copies of
ID data blocks are made.

===================================================================

M	source/blender/blenkernel/intern/simulation.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/simulation.cc b/source/blender/blenkernel/intern/simulation.cc
index f08051510db..eacb854950d 100644
--- a/source/blender/blenkernel/intern/simulation.cc
+++ b/source/blender/blenkernel/intern/simulation.cc
@@ -172,13 +172,14 @@ static void simulation_blend_write(BlendWriter *writer, ID *id, const void *id_a
         ParticleSimulationState *particle_state = (ParticleSimulationState *)state;
 
         CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
+        CustomData attributes_shallow_copy = particle_state->attributes;
         CustomData_blend_write_prepare(
-            &particle_state->attributes, &players, players_buff, ARRAY_SIZE(players_buff));
+            &attributes_shallow_copy, &players, players_buff, ARRAY_SIZE(players_buff));
 
         BLO_write_struct(writer, ParticleSimulationState, particle_state);
 
         CustomData_blend_write(writer,
-                               &particle_state->attributes,
+                               &attributes_shallow_copy,
                                players,
                                particle_state->tot_particles,
                                CD_MASK_ALL,



More information about the Bf-blender-cvs mailing list