[Bf-blender-cvs] [231d08cbb11] master: Multires: Fix memory leak when multires is at level 0

Sergey Sharybin noreply at git.blender.org
Mon Sep 7 16:44:25 CEST 2020


Commit: 231d08cbb11277ebfe1c1700124ced9ef50229d8
Author: Sergey Sharybin
Date:   Mon Sep 7 16:43:34 2020 +0200
Branches: master
https://developer.blender.org/rB231d08cbb11277ebfe1c1700124ced9ef50229d8

Multires: Fix memory leak when multires is at level 0

There is no SubdivCCG created in this case, meaning ownership of the Subdiv
was not altered.

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

M	source/blender/modifiers/intern/MOD_multires.c

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

diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index 7bdc1da33c2..03e7f0a235b 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -205,6 +205,13 @@ static Mesh *multires_as_ccg(MultiresModifierData *mmd,
   }
   BKE_subdiv_displacement_attach_from_multires(subdiv, mesh, mmd);
   result = BKE_subdiv_to_ccg_mesh(subdiv, &ccg_settings, mesh);
+
+  /* NOTE: CCG becomes an owner of Subdiv descriptor, so can not share
+   * this pointer. Not sure if it's needed, but might have a second look
+   * on the ownership model here. */
+  MultiresRuntimeData *runtime_data = mmd->modifier.runtime;
+  runtime_data->subdiv = NULL;
+
   return result;
 }
 
@@ -261,10 +268,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
       sculpt_session->mpoly = NULL;
       sculpt_session->mloop = NULL;
     }
-    /* NOTE: CCG becomes an owner of Subdiv descriptor, so can not share
-     * this pointer. Not sure if it's needed, but might have a second look
-     * on the ownership model here. */
-    runtime_data->subdiv = NULL;
     // BKE_subdiv_stats_print(&subdiv->stats);
   }
   else {



More information about the Bf-blender-cvs mailing list