add missing NULL checks from BKE_constraint_get_typeinfo(), so constraints from the...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 3 Aug 2013 22:03:15 +0000 (22:03 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 3 Aug 2013 22:03:15 +0000 (22:03 +0000)
also remove some redundant NULL checks.

source/blender/blenkernel/intern/movieclip.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/object/object_modifier.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform.c

index e8550e12e4f29a129e89bd7d4c668ee3b4c92d64..42dd289ee33a37eb1e2d1306e2bd197175478962 100644 (file)
@@ -1439,21 +1439,19 @@ void BKE_movieclip_unlink(Main *bmain, MovieClip *clip)
                bConstraint *con;
 
                for (con = ob->constraints.first; con; con = con->next) {
-                       bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
-
-                       if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
+                       if (con->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
                                bFollowTrackConstraint *data = (bFollowTrackConstraint *) con->data;
 
                                if (data->clip == clip)
                                        data->clip = NULL;
                        }
-                       else if (cti->type == CONSTRAINT_TYPE_CAMERASOLVER) {
+                       else if (con->type == CONSTRAINT_TYPE_CAMERASOLVER) {
                                bCameraSolverConstraint *data = (bCameraSolverConstraint *) con->data;
 
                                if (data->clip == clip)
                                        data->clip = NULL;
                        }
-                       else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
+                       else if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
                                bObjectSolverConstraint *data = (bObjectSolverConstraint *) con->data;
 
                                if (data->clip == clip)
index 72b426a155a7618621e605ce1409ed5666ea7b81..80a09b4701cfc941f8f9d1097367f22a8f8d9246 100644 (file)
@@ -8174,12 +8174,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        for (ob = main->object.first; ob; ob = ob->id.next) {
                                bConstraint *con;
                                for (con = ob->constraints.first; con; con = con->next) {
-                                       bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
-                                       
-                                       if (!cti)
-                                               continue;
-                                       
-                                       if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
+                                       if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
                                                bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data;
                                                
                                                if (data->invmat[3][3] == 0.0f)
index b9c97c32fc996d48fecb430716a5874bb90a2a86..651ee8b295a423812734fd5286c2bbbf69d8de76 100644 (file)
@@ -875,7 +875,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
        int mode_orig = ob ? ob->mode : 0;
        
-       if (!ob || !md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
+       if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
                return OPERATOR_CANCELLED;
 
        WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -919,7 +919,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
 
-       if (!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md))
+       if (!md || !ED_object_modifier_move_up(op->reports, ob, md))
                return OPERATOR_CANCELLED;
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -958,7 +958,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
 
-       if (!ob || !md || !ED_object_modifier_move_down(op->reports, ob, md))
+       if (!md || !ED_object_modifier_move_down(op->reports, ob, md))
                return OPERATOR_CANCELLED;
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -999,7 +999,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
        int apply_as = RNA_enum_get(op->ptr, "apply_as");
 
-       if (!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) {
+       if (!md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) {
                return OPERATOR_CANCELLED;
        }
 
@@ -1049,7 +1049,7 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
        
-       if (!ob || !md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md))
+       if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md))
                return OPERATOR_CANCELLED;
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -1088,7 +1088,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
 
-       if (!ob || !md || !ED_object_modifier_copy(op->reports, ob, md))
+       if (!md || !ED_object_modifier_copy(op->reports, ob, md))
                return OPERATOR_CANCELLED;
 
        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
index 797ba5a223634ff768a60d27f000fee0386efb6b..f3105284a39e94bb01e2319b645c58f478d1ba9d 100644 (file)
@@ -3094,8 +3094,8 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
        BMVert *eve_act = NULL;
        bool use_occlude_wire = (v3d->flag2 & V3D_OCCLUDE_WIRE) && (dt > OB_WIRE);
        
-       // if (cageDM)  BLI_assert(!(cageDM->dirty & DM_DIRTY_NORMALS));
-       if (finalDM) BLI_assert(!(finalDM->dirty & DM_DIRTY_NORMALS));
+       // BLI_assert(!cageDM || !(cageDM->dirty & DM_DIRTY_NORMALS));
+       BLI_assert(!finalDM || !(finalDM->dirty & DM_DIRTY_NORMALS));
 
        if (em->bm->selected.last) {
                BMEditSelection *ese = em->bm->selected.last;
@@ -7253,23 +7253,19 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
                        cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
                        
                        for (curcon = list->first; curcon; curcon = curcon->next) {
-                               bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(curcon);
-                               ListBase targets = {NULL, NULL};
-                               bConstraintTarget *ct;
-                               
-                               if (ELEM(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_OBJECTSOLVER)) {
+                               if (ELEM(curcon->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_OBJECTSOLVER)) {
                                        /* special case for object solver and follow track constraints because they don't fill
                                         * constraint targets properly (design limitation -- scene is needed for their target
                                         * but it can't be accessed from get_targets callvack) */
 
                                        Object *camob = NULL;
 
-                                       if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
+                                       if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
                                                bFollowTrackConstraint *data = (bFollowTrackConstraint *)curcon->data;
 
                                                camob = data->camera ? data->camera : scene->camera;
                                        }
-                                       else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
+                                       else if (curcon->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
                                                bObjectSolverConstraint *data = (bObjectSolverConstraint *)curcon->data;
 
                                                camob = data->camera ? data->camera : scene->camera;
@@ -7284,26 +7280,33 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
                                                setlinestyle(0);
                                        }
                                }
-                               else if ((curcon->flag & CONSTRAINT_EXPAND) && (cti->get_constraint_targets)) {
-                                       cti->get_constraint_targets(curcon, &targets);
-                                       
-                                       for (ct = targets.first; ct; ct = ct->next) {
-                                               /* calculate target's matrix */
-                                               if (cti->get_target_matrix)
-                                                       cti->get_target_matrix(curcon, cob, ct, BKE_scene_frame_get(scene));
-                                               else
-                                                       unit_m4(ct->matrix);
-                                               
-                                               setlinestyle(3);
-                                               glBegin(GL_LINES);
-                                               glVertex3fv(ct->matrix[3]);
-                                               glVertex3fv(ob->obmat[3]);
-                                               glEnd();
-                                               setlinestyle(0);
+                               else {
+                                       bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(curcon);
+
+                                       if ((cti && cti->get_constraint_targets) && (curcon->flag & CONSTRAINT_EXPAND)) {
+                                               ListBase targets = {NULL, NULL};
+                                               bConstraintTarget *ct;
+
+                                               cti->get_constraint_targets(curcon, &targets);
+
+                                               for (ct = targets.first; ct; ct = ct->next) {
+                                                       /* calculate target's matrix */
+                                                       if (cti->get_target_matrix)
+                                                               cti->get_target_matrix(curcon, cob, ct, BKE_scene_frame_get(scene));
+                                                       else
+                                                               unit_m4(ct->matrix);
+
+                                                       setlinestyle(3);
+                                                       glBegin(GL_LINES);
+                                                       glVertex3fv(ct->matrix[3]);
+                                                       glVertex3fv(ob->obmat[3]);
+                                                       glEnd();
+                                                       setlinestyle(0);
+                                               }
+
+                                               if (cti->flush_constraint_targets)
+                                                       cti->flush_constraint_targets(curcon, &targets, 1);
                                        }
-                                       
-                                       if (cti->flush_constraint_targets)
-                                               cti->flush_constraint_targets(curcon, &targets, 1);
                                }
                        }
                        
index 6c854ef679520dbc086dbffd75b2c3581ab98c4a..f67fab3429afb8d30de558d91cb584292e469083 100644 (file)
@@ -5880,14 +5880,8 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
 
        t->values[0] = final;
 
-       /*do stuff here*/
-       if (t->customData) {
-               doEdgeSlide(t, final);
-       }
-       else {
-               BLI_strncpy(str, IFACE_("Invalid Edge Selection"), MAX_INFO_LEN);
-               t->state = TRANS_CANCEL;
-       }
+       /* do stuff here */
+       doEdgeSlide(t, final);
 
        recalcData(t);
 
@@ -6394,14 +6388,8 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
        ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Alt or (C)lamp: %s"), is_clamp ? on_str : off_str);
        /* done with header string */
 
-       /*do stuff here*/
-       if (t->customData) {
-               doVertSlide(t, final);
-       }
-       else {
-               BLI_strncpy(str, IFACE_("Invalid Vert Selection"), MAX_INFO_LEN);
-               t->state = TRANS_CANCEL;
-       }
+       /* do stuff here */
+       doVertSlide(t, final);
 
        recalcData(t);