GPv3: LinArt: Handle shared cache for v3.

Shared cache in GPv3 line art is created before
`MOD_lineart_compute_feature_lines_v3`, the function will create its own
cache and overwrite the old one, causing memory leak. Now all code paths
have been fixed.
This commit is contained in:
YimingWu
2024-05-16 12:30:03 +08:00
parent 66a338741e
commit 401401b7f2
2 changed files with 6 additions and 3 deletions

View File

@@ -5068,8 +5068,11 @@ bool MOD_lineart_compute_feature_lines_v3(Depsgraph *depsgraph,
}
}
LineartCache *lc = MOD_lineart_init_cache();
*cached_result = lc;
LineartCache *lc = *cached_result;
if (!lc) {
lc = MOD_lineart_init_cache();
*cached_result = lc;
}
ld = lineart_create_render_buffer_v3(scene,
&lmd,

View File

@@ -827,7 +827,7 @@ static void generate_strokes(ModifierData &md,
lmd.flags,
lmd.calculation_flags);
if (!(lmd.flags & MOD_LINEART_USE_CACHE)) {
if ((!(lmd.flags & MOD_LINEART_USE_CACHE)) && (&first_lineart != &lmd)) {
/* Clear local cache. */
if (local_lc != first_lineart.shared_cache) {
MOD_lineart_clear_cache(&local_lc);