diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-02-01 07:15:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-02-01 07:23:29 +0300 |
commit | c2508b0aaf38a511eb419e340b3aa8a6f981a8c4 (patch) | |
tree | 2bd523f510fd1794502fb822e7094577a5bf0315 /source/blender/editors/transform/transform.h | |
parent | 17429dce0075a5863030f51741fc3c286ddace1d (diff) |
Fix transform crash in rare cases
In some cases transform modes would use the custom-data pointer,
other times the transform conversion functions would.
However with some combinations (bone mirror + bend for eg),
both conversion & transform mode would use this pointer causing a crash.
Fix this by having 2 custom-data pointers:
one for the mode, another for the data-type.
This also simplifies time-slide which was conditionally mixing mode/type data in the one array.
Diffstat (limited to 'source/blender/editors/transform/transform.h')
-rw-r--r-- | source/blender/editors/transform/transform.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index f6b4d7da57f..c6d801f7160 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -357,6 +357,12 @@ typedef struct MouseInput { } virtual_mval; } MouseInput; +typedef struct TransCustomData { + void *data; + void (*free_cb)(struct TransInfo *, struct TransCustomData *); + unsigned int use_free : 1; +} TransCustomData; + typedef struct TransInfo { int mode; /* current mode */ int flag; /* generic flags for special behaviors */ @@ -408,8 +414,22 @@ typedef struct TransInfo { struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */ - void *customData; /* Per Transform custom data */ - void (*customFree)(struct TransInfo *); /* if a special free function is needed */ + /** + * Rule of thumb for choosing between mode/type: + * - If transform mode uses the data, assign to `mode` + * (typically in transform.c). + * - If conversion uses the data as an extension to the #TransData, assign to `type` + * (typically in transform_conversion.c). + */ + struct { + /* owned by the mode (grab, scale, bend... )*/ + union { + TransCustomData mode, first_elem; + }; + /* owned by the type (mesh, armature, nla...) */ + TransCustomData type; + } custom; +#define TRANS_CUSTOM_DATA_ELEM_MAX (sizeof(((TransInfo *)NULL)->custom) / sizeof(TransCustomData)) /*************** NEW STUFF *********************/ short launch_event; /* event type used to launch transform */ @@ -484,7 +504,6 @@ typedef struct TransInfo { #define T_2D_EDIT (1 << 15) #define T_CLIP_UV (1 << 16) -#define T_FREE_CUSTOMDATA (1 << 17) /* auto-ik is on */ #define T_AUTOIK (1 << 18) @@ -758,11 +777,11 @@ int getTransformOrientation_ex(const struct bContext *C, float normal[3], float int getTransformOrientation(const struct bContext *C, float normal[3], float plane[3]); void freeEdgeSlideTempFaces(EdgeSlideData *sld); -void freeEdgeSlideVerts(TransInfo *t); +void freeEdgeSlideVerts(TransInfo *t, TransCustomData *custom_data); void projectEdgeSlideData(TransInfo *t, bool is_final); void freeVertSlideTempFaces(VertSlideData *sld); -void freeVertSlideVerts(TransInfo *t); +void freeVertSlideVerts(TransInfo *t, TransCustomData *custom_data); void projectVertSlideData(TransInfo *t, bool is_final); |