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:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-07-27 15:18:45 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-07-27 16:19:36 +0300
commit4c5537ed428f33b2996f1965b93945a1c9d491b4 (patch)
tree98f6fb87e52eac11046cfd5740d98e36a6dc153a /source/blender
parent7d014bca9156ebc2d08b7c041a109d28df50cdec (diff)
Copy on write: Make sure freeing evaluated mesh does not cause crash when re-evaluating the object
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/object.c2
-rw-r--r--source/blender/blenkernel/intern/object_update.c5
2 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 858c60824fc..efe8498ace5 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -365,6 +365,8 @@ void BKE_object_free_derived_caches(Object *ob)
}
if (ob->mesh_evaluated != NULL) {
+ /* Restore initial pointer. */
+ ob->data = ob->mesh_evaluated->id.newid;
/* Evaluated mesh points to edit mesh, but does not own it. */
ob->mesh_evaluated->edit_btmesh = NULL;
BKE_mesh_free(ob->mesh_evaluated);
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index a478671d8a0..0bbfbb8a4e7 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -377,6 +377,11 @@ void BKE_object_eval_uber_data(EvaluationContext *eval_ctx,
/* NOTE: Watch out, some tools might need it!
* So keep around for now..
*/
+ /* Store original ID as a pointer in evaluated ID.
+ * This way we can restore original object data when we are freeing
+ * evaluated mesh.
+ */
+ new_mesh->id.newid = &mesh->id;
}
#if 0
if (ob->derivedFinal != NULL) {