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:
authorFalk David <falkdavid@gmx.de>2022-03-03 17:48:53 +0300
committerFalk David <falkdavid@gmx.de>2022-03-03 18:01:23 +0300
commite8dc82311d1a7012adaacc93bcc5e92c0fd7adbf (patch)
tree910f6900e1d1c291af12c091d8afa907c01c39ed /source/blender/blenkernel
parent6e487228a5952ac538718e56241d8d2082baa279 (diff)
Fix T96145: GPencil eval data not updated correctly
When removing a modifier, changing the layer transform or updating the parent of a grease pencil object that has a multi-user datablock and animation data, the eval data is not updated properly (after a frame change). This can also cause memory leaks. The fix makes sure that we free and reset any runtime copy (`ob->runtime.gpd_eval`) in `BKE_gpencil_prepare_eval_data`. Note: As far as we can tell, `ob->runtime.gpd_orig` is unused and could be removed. The assignment in `BKE_gpencil_prepare_eval_data` seemed to be unnecessary. Co-authored-by: @yann-lty Reviewed By: antoniov Maniphest Tasks: T96145 Differential Revision: https://developer.blender.org/D14236
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/gpencil_modifier.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 3d9043e6800..bc3aa88d096 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -682,31 +682,41 @@ void BKE_gpencil_prepare_eval_data(Depsgraph *depsgraph, Scene *scene, Object *o
}
}
- const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_eval);
- const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd_eval);
+ DEG_debug_print_eval(depsgraph, __func__, gpd_eval->id.name, gpd_eval);
+
+ /* Delete any previously created runtime copy. */
+ if (ob->runtime.gpd_eval != NULL) {
+ /* Make sure to clear the pointer in case the runtime eval data points to the same data block.
+ * This can happen when the gpencil data block was not tagged for a depsgraph update after last
+ * call to this function. */
+ if (gpd_eval == ob->runtime.gpd_eval) {
+ gpd_eval = NULL;
+ }
+ BKE_gpencil_eval_delete(ob->runtime.gpd_eval);
+ ob->runtime.gpd_eval = NULL;
+ ob->data = gpd_eval;
+ }
+
+ const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_orig);
+ const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd_orig);
const bool do_modifiers = (bool)((!is_multiedit) && (!is_curve_edit) &&
- (ob->greasepencil_modifiers.first != NULL) &&
+ (ob_orig->greasepencil_modifiers.first != NULL) &&
(!GPENCIL_SIMPLIFY_MODIF(scene)));
if ((!do_modifiers) && (!do_parent) && (!do_transform)) {
+ BLI_assert(ob->data != NULL);
return;
}
- DEG_debug_print_eval(depsgraph, __func__, gpd_eval->id.name, gpd_eval);
/* If only one user, don't need a new copy, just update data of the frame. */
if (gpd_orig->id.us == 1) {
- ob->runtime.gpd_eval = NULL;
+ BLI_assert(ob->data != NULL);
gpencil_copy_activeframe_to_eval(depsgraph, scene, ob, ob_orig->data, gpd_eval);
return;
}
- /* Copy full Datablock to evaluated version. */
- ob->runtime.gpd_orig = gpd_orig;
- if (ob->runtime.gpd_eval != NULL) {
- BKE_gpencil_eval_delete(ob->runtime.gpd_eval);
- ob->runtime.gpd_eval = NULL;
- ob->data = ob->runtime.gpd_orig;
- }
- ob->runtime.gpd_eval = gpencil_copy_for_eval(ob->runtime.gpd_orig);
+ /* Copy full datablock to evaluated version. */
+ ob->runtime.gpd_eval = gpencil_copy_for_eval(gpd_orig);
+ /* Overwrite ob->data with gpd_eval here. */
gpencil_assign_object_eval(ob);
BKE_gpencil_update_orig_pointers(ob_orig, ob);
}