[Bf-blender-cvs] [3e78c9e5bb1] master: Fix T91766: NLA Editor - Segmentation fault on strip resize

Germano Cavalcante noreply at git.blender.org
Tue Sep 28 15:24:22 CEST 2021


Commit: 3e78c9e5bb179e84d542bc698fc6f6d7c111d1e1
Author: Germano Cavalcante
Date:   Tue Sep 28 10:23:57 2021 -0300
Branches: master
https://developer.blender.org/rB3e78c9e5bb179e84d542bc698fc6f6d7c111d1e1

Fix T91766: NLA Editor - Segmentation fault on strip resize

NLA and Dope Sheet use a specific transform operation to scale.

Unlike the conventional resize operation, `TIME_SCALE` operates on `td->val`.

This is a bit outside the convention of transform operators.

The expected thing in this case would be to work in `td->loc` and use the conventional resize operator.

But for now, to fix the problem, use `td->loc` in the `TIME_SCALE` operation.

This commit also brings a cleanup in the style of some comments and removing unnecessary `memset`.

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

M	source/blender/editors/transform/transform_convert_nla.c
M	source/blender/editors/transform/transform_mode_timescale.c

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

diff --git a/source/blender/editors/transform/transform_convert_nla.c b/source/blender/editors/transform/transform_convert_nla.c
index 7e5b80c2453..acef8a666e3 100644
--- a/source/blender/editors/transform/transform_convert_nla.c
+++ b/source/blender/editors/transform/transform_convert_nla.c
@@ -208,30 +208,18 @@ void createTransNlaData(bContext *C, TransInfo *t)
               /* just set tdn to assume that it only has one handle for now */
               tdn->handle = -1;
 
-              /* now, link the transform data up to this data */
-              if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
-                td->loc = tdn->h1;
-                copy_v3_v3(td->iloc, tdn->h1);
+              /* Now, link the transform data up to this data. */
+              td->loc = tdn->h1;
+              copy_v3_v3(td->iloc, tdn->h1);
 
-                /* store all the other gunk that is required by transform */
+              if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
+                /* Store all the other gunk that is required by transform. */
                 copy_v3_v3(td->center, center);
-                memset(td->axismtx, 0, sizeof(td->axismtx));
                 td->axismtx[2][2] = 1.0f;
-
-                td->ext = NULL;
-                td->val = NULL;
-
                 td->flag |= TD_SELECTED;
-                td->dist = 0.0f;
-
                 unit_m3(td->mtx);
                 unit_m3(td->smtx);
               }
-              else {
-                /* time scaling only needs single value */
-                td->val = &tdn->h1[0];
-                td->ival = tdn->h1[0];
-              }
 
               td->extra = tdn;
               td++;
@@ -241,30 +229,18 @@ void createTransNlaData(bContext *C, TransInfo *t)
                * then we're doing both, otherwise, only end */
               tdn->handle = (tdn->handle) ? 2 : 1;
 
-              /* now, link the transform data up to this data */
-              if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
-                td->loc = tdn->h2;
-                copy_v3_v3(td->iloc, tdn->h2);
+              /* Now, link the transform data up to this data. */
+              td->loc = tdn->h2;
+              copy_v3_v3(td->iloc, tdn->h2);
 
-                /* store all the other gunk that is required by transform */
+              if (ELEM(t->mode, TFM_TRANSLATION, TFM_TIME_EXTEND)) {
+                /* Store all the other gunk that is required by transform. */
                 copy_v3_v3(td->center, center);
-                memset(td->axismtx, 0, sizeof(td->axismtx));
                 td->axismtx[2][2] = 1.0f;
-
-                td->ext = NULL;
-                td->val = NULL;
-
                 td->flag |= TD_SELECTED;
-                td->dist = 0.0f;
-
                 unit_m3(td->mtx);
                 unit_m3(td->smtx);
               }
-              else {
-                /* time scaling only needs single value */
-                td->val = &tdn->h2[0];
-                td->ival = tdn->h2[0];
-              }
 
               td->extra = tdn;
               td++;
diff --git a/source/blender/editors/transform/transform_mode_timescale.c b/source/blender/editors/transform/transform_mode_timescale.c
index 50fd714727b..0a7ae54982e 100644
--- a/source/blender/editors/transform/transform_mode_timescale.c
+++ b/source/blender/editors/transform/transform_mode_timescale.c
@@ -87,7 +87,7 @@ static void applyTimeScaleValue(TransInfo *t, float value)
       }
 
       /* now, calculate the new value */
-      *(td->val) = ((td->ival - startx) * fac) + startx;
+      td->loc[0] = ((td->iloc[0] - startx) * fac) + startx;
     }
   }
 }



More information about the Bf-blender-cvs mailing list