diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2021-01-04 16:14:13 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2021-01-05 17:31:40 +0300 |
commit | 36ae6e66c1068b5579c725c3353d39afe96c9d29 (patch) | |
tree | 43c7d66dc8d7f32cadd5d046c217ecb4a1792c5b /source | |
parent | 1f41bdc6f37fd091bb5649436f68335b10ade51f (diff) |
Fix T84367: Fix crash when showing invalid/legacy constraints
Exposed by rBeaa44afe703e.
Definition for CONSTRAINT_TYPE_NULL is not totally clear (it is set for
constraints without data, see an old comment from Ton), but for these, a
TypeInfo cannot be fetched.
Avoid processing those constraints in UI code, just do nothing instead.
Maniphest Tasks: T84367
Differential Revision: https://developer.blender.org/D9987
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index a035ab86579..e9a6809f170 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2301,6 +2301,11 @@ static void object_constraint_panel_id(void *md_link, char *r_name) bConstraint *con = (bConstraint *)md_link; const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(con->type); + /* Cannot get TypeInfo for invalid/legacy constraints. */ + if (cti == NULL) { + return; + } + strcpy(r_name, CONSTRAINT_TYPE_PANEL_PREFIX); strcat(r_name, cti->structName); } @@ -2310,6 +2315,11 @@ static void bone_constraint_panel_id(void *md_link, char *r_name) bConstraint *con = (bConstraint *)md_link; const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(con->type); + /* Cannot get TypeInfo for invalid/legacy constraints. */ + if (cti == NULL) { + return; + } + strcpy(r_name, CONSTRAINT_BONE_TYPE_PANEL_PREFIX); strcat(r_name, cti->structName); } @@ -2340,6 +2350,10 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_ UI_panels_free_instanced(C, region); bConstraint *con = (constraints == NULL) ? NULL : constraints->first; for (int i = 0; con; i++, con = con->next) { + /* Dont show invalid/legacy constraints. */ + if (con->type == CONSTRAINT_TYPE_NULL) { + continue; + } /* Dont show temporary constraints (AutoIK and targetless IK constraints). */ if (con->type == CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data = con->data; @@ -2369,6 +2383,10 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_ /* Assuming there's only one group of instanced panels, update the custom data pointers. */ Panel *panel = region->panels.first; LISTBASE_FOREACH (bConstraint *, con, constraints) { + /* Dont show invalid/legacy constraints. */ + if (con->type == CONSTRAINT_TYPE_NULL) { + continue; + } /* Dont show temporary constraints (AutoIK and targetless IK constraints). */ if (con->type == CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data = con->data; |