From b3afbcab8ff2330c1473647be330a3ffe9b11885 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 Feb 2014 06:07:10 +1100 Subject: ListBase API: add utility api funcs for clearing and checking empty --- .../blender/editors/animation/anim_channels_edit.c | 14 +++++----- source/blender/editors/animation/anim_filter.c | 32 +++++++++++----------- .../blender/editors/animation/keyframes_general.c | 10 +++---- source/blender/editors/animation/keyframing.c | 2 +- source/blender/editors/animation/keyingsets.c | 2 +- source/blender/editors/armature/armature_edit.c | 4 +-- source/blender/editors/armature/armature_utils.c | 5 ++-- .../editors/armature/editarmature_retarget.c | 4 +-- .../blender/editors/armature/editarmature_sketch.c | 9 +++--- source/blender/editors/armature/pose_group.c | 2 +- source/blender/editors/armature/pose_lib.c | 2 +- source/blender/editors/armature/pose_utils.c | 2 +- source/blender/editors/curve/editcurve.c | 10 +++---- .../blender/editors/gpencil/editaction_gpencil.c | 6 ++-- source/blender/editors/gpencil/gpencil_edit.c | 2 +- source/blender/editors/gpencil/gpencil_undo.c | 4 +-- source/blender/editors/interface/interface.c | 4 +-- .../blender/editors/interface/interface_handlers.c | 7 +++-- source/blender/editors/interface/interface_icons.c | 2 +- .../blender/editors/interface/interface_layout.c | 4 +-- source/blender/editors/mask/mask_ops.c | 2 +- source/blender/editors/mesh/editmesh_knife.c | 2 +- source/blender/editors/mesh/editmesh_select.c | 2 +- source/blender/editors/metaball/mball_edit.c | 3 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_edit.c | 3 +- source/blender/editors/object/object_lattice.c | 2 +- source/blender/editors/object/object_modifier.c | 2 +- source/blender/editors/object/object_select.c | 2 +- source/blender/editors/object/object_vgroup.c | 8 +++--- source/blender/editors/physics/particle_edit.c | 6 ++-- source/blender/editors/screen/area.c | 6 ++-- source/blender/editors/screen/screen_edit.c | 10 +++---- source/blender/editors/sculpt_paint/paint_undo.c | 2 +- source/blender/editors/sculpt_paint/paint_utils.c | 3 +- source/blender/editors/sculpt_paint/paint_vertex.c | 2 +- .../editors/sculpt_paint/paint_vertex_proj.c | 3 +- .../editors/space_buttons/buttons_texture.c | 2 +- .../blender/editors/space_console/space_console.c | 6 ++-- source/blender/editors/space_graph/graph_draw.c | 2 +- source/blender/editors/space_graph/graph_edit.c | 2 +- source/blender/editors/space_graph/graph_select.c | 4 +-- source/blender/editors/space_image/image_buttons.c | 2 +- source/blender/editors/space_image/image_ops.c | 2 +- source/blender/editors/space_nla/nla_channels.c | 2 +- source/blender/editors/space_nla/nla_edit.c | 6 ++-- source/blender/editors/space_node/node_add.c | 5 ++-- source/blender/editors/space_node/node_edit.c | 2 +- .../editors/space_node/node_relationships.c | 4 +-- source/blender/editors/space_node/node_templates.c | 2 +- source/blender/editors/space_node/space_node.c | 4 +-- .../blender/editors/space_outliner/outliner_draw.c | 2 +- .../blender/editors/space_outliner/outliner_tree.c | 4 +-- .../editors/space_outliner/space_outliner.c | 2 +- .../editors/space_sequencer/sequencer_edit.c | 5 ++-- source/blender/editors/space_time/space_time.c | 2 +- source/blender/editors/space_view3d/drawobject.c | 6 ++-- source/blender/editors/space_view3d/view3d_draw.c | 2 +- source/blender/editors/space_view3d/view3d_ruler.c | 2 +- source/blender/editors/space_view3d/view3d_view.c | 2 +- .../editors/transform/transform_conversions.c | 8 +++--- source/blender/editors/transform/transform_snap.c | 4 +-- 62 files changed, 136 insertions(+), 135 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 7630754db1a..efd057d4e76 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -80,7 +80,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f /* try to build list of filtered items */ ANIM_animdata_filter(ac, &anim_data, filter, data, datatype); - if (anim_data.first == NULL) + if (BLI_listbase_is_empty(&anim_data)) return; /* only clear the 'active' flag for the channels of the same type */ @@ -550,7 +550,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f /* if group has no more channels, remove it too, * otherwise can have many dangling groups [#33541] */ - if (agrp->channels.first == NULL) { + if (BLI_listbase_is_empty(&agrp->channels)) { BLI_freelinkN(&act->groups, agrp); } } @@ -565,7 +565,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f * channel list that are empty, and linger around long after the data they * are for has disappeared (and probably won't come back). */ - if ((act->curves.first == NULL) && (adt->flag & ADT_NLA_EDIT_ON) == 0) { + if (BLI_listbase_is_empty(&act->curves) && (adt->flag & ADT_NLA_EDIT_ON) == 0) { id_us_min(&act->id); adt->action = NULL; } @@ -844,7 +844,7 @@ static void rearrange_animchannel_flatten_islands(ListBase *islands, ListBase *s tReorderChannelIsland *island, *isn = NULL; /* make sure srcList is empty now */ - BLI_assert(srcList->first == NULL); + BLI_assert(BLI_listbase_is_empty(srcList)); /* go through merging islands */ for (island = islands->first; island; island = isn) { @@ -866,7 +866,7 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re short done = FALSE; /* don't waste effort on an empty list */ - if (list->first == NULL) + if (BLI_listbase_is_empty(list)) return 0; /* group channels into islands */ @@ -1221,7 +1221,7 @@ static void animchannels_group_channels(bAnimContext *ac, bAnimListElem *adt_ref /* remove F-Curve from group, then group too if it is now empty */ action_groups_remove_channel(act, fcu); - if ((grp) && (grp->channels.first == NULL)) { + if ((grp) && BLI_listbase_is_empty(&grp->channels)) { BLI_freelinkN(&act->groups, grp); } @@ -1326,7 +1326,7 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) BLI_addtail(&act->curves, fcu); /* delete group if it is now empty */ - if (agrp->channels.first == NULL) { + if (BLI_listbase_is_empty(&agrp->channels)) { BLI_freelinkN(&act->groups, agrp); } } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 3744e50db34..9d54d938cc7 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1175,7 +1175,7 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } @@ -1429,7 +1429,7 @@ static size_t animdata_filter_gpencil(ListBase *anim_data, void *UNUSED(data), i /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } } @@ -1496,7 +1496,7 @@ static size_t animdata_filter_mask(ListBase *anim_data, void *UNUSED(data), int /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } } @@ -1532,7 +1532,7 @@ static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBase *anim /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } @@ -1614,7 +1614,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } } @@ -1659,7 +1659,7 @@ static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBase *anim_data, /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } @@ -1757,7 +1757,7 @@ static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data, /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } @@ -1877,7 +1877,7 @@ static size_t animdata_filter_ds_modifiers(bAnimContext *ac, ListBase *anim_data if (afm.items) { /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &afm.tmp_data); - BLI_assert((afm.tmp_data.first == afm.tmp_data.last) && (afm.tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&afm.tmp_data)); items += afm.items; } @@ -1920,7 +1920,7 @@ static size_t animdata_filter_ds_particles(bAnimContext *ac, ListBase *anim_data /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } } @@ -2068,7 +2068,7 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } @@ -2102,7 +2102,7 @@ static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBase *anim_data, /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } @@ -2158,7 +2158,7 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } @@ -2228,7 +2228,7 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } @@ -2270,7 +2270,7 @@ static size_t animdata_filter_ds_world(bAnimContext *ac, ListBase *anim_data, bD /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } @@ -2324,7 +2324,7 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } @@ -2381,7 +2381,7 @@ static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_d /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 0ead68c4d4a..6a359b0e6d0 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -505,7 +505,7 @@ void free_anim_copybuf(void) } /* restore initial state */ - animcopybuf.first = animcopybuf.last = NULL; + BLI_listbase_clear(&animcopybuf); animcopy_firstframe = 999999999.0f; animcopy_lastframe = -999999999.0f; } @@ -774,19 +774,19 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, const Scene *scene = (ac->scene); - const short from_single = (animcopybuf.first == animcopybuf.last); - const short to_simple = (anim_data->first == anim_data->last); + const bool from_single = BLI_listbase_is_single(&animcopybuf); + const bool to_simple = BLI_listbase_is_single(anim_data); float offset = 0.0f; int pass; /* check if buffer is empty */ - if (animcopybuf.first == NULL) { + if (BLI_listbase_is_empty(&animcopybuf)) { BKE_report(ac->reports, RPT_ERROR, "No animation data in buffer to paste"); return -1; } - if (anim_data->first == NULL) { + if (BLI_listbase_is_empty(anim_data)) { BKE_report(ac->reports, RPT_ERROR, "No selected F-Curves to paste into"); return -1; } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index a69403b085f..41f39c1d33a 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -183,7 +183,7 @@ FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr, fcu = MEM_callocN(sizeof(FCurve), "FCurve"); fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED); - if (act->curves.first == NULL) + if (BLI_listbase_is_empty(&act->curves)) fcu->flag |= FCURVE_ACTIVE; /* first one added active */ /* store path - make copy, and store that */ diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index b0b1ae3b0c9..74bd4960838 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -892,7 +892,7 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) /* if we don't have any paths now, then this still qualifies as invalid context */ // FIXME: we need some error conditions (to be retrieved from the iterator why this failed!) - if (ks->paths.first == NULL) + if (BLI_listbase_is_empty(&ks->paths)) return MODIFYKEY_INVALID_CONTEXT; } else { diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 1819492c346..db57e762848 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -808,7 +808,7 @@ static int armature_merge_exec(bContext *C, wmOperator *op) /* get chains (ends on chains) */ chains_find_tips(arm->edbo, &chains); - if (chains.first == NULL) return OPERATOR_CANCELLED; + if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED; /* each 'chain' is the last bone in the chain (with no children) */ for (chain = chains.first; chain; chain = nchain) { @@ -916,7 +916,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) /* get chains of bones (ends on chains) */ chains_find_tips(arm->edbo, &chains); - if (chains.first == NULL) return OPERATOR_CANCELLED; + if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED; /* ensure that mirror bones will also be operated on */ armature_tag_select_mirrored(arm); diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 7c7027641d7..52e3285d240 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -655,8 +655,7 @@ static void ED_armature_ebone_listbase_free(ListBase *lb) MEM_freeN(ebone); } - lb->first = NULL; - lb->last = NULL; + BLI_listbase_clear(lb); } static void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src) @@ -664,7 +663,7 @@ static void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src) EditBone *ebone_src; EditBone *ebone_dst; - BLI_assert(lb_dst->first == NULL); + BLI_assert(BLI_listbase_is_empty(lb_dst)); for (ebone_src = lb_src->first; ebone_src; ebone_src = ebone_src->next) { ebone_dst = MEM_dupallocN(ebone_src); diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 4ea564b46ce..a0411f246c8 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -944,7 +944,7 @@ static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigAr joined_arc1->tail = joined_arc2->tail; - joined_arc2->edges.first = joined_arc2->edges.last = NULL; + BLI_listbase_clear(&joined_arc2->edges); BLI_removeArc((BGraph *)rg, (BArc *)joined_arc2); @@ -2593,7 +2593,7 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg) template_rigg = armatureSelectedToGraph(C, ob, ob->data); } - if (template_rigg->arcs.first == NULL) { + if (BLI_listbase_is_empty(&template_rigg->arcs)) { // XXX // error("No Template and no deforming bones selected"); return; diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index a1ec0b595b0..68141fb85f1 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -979,7 +979,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S float mvalf[2]; BLI_freelistN(&sketch->depth_peels); - sketch->depth_peels.first = sketch->depth_peels.last = NULL; + BLI_listbase_clear(&sketch->depth_peels); mvalf[0] = dd->mval[0]; mvalf[1] = dd->mval[1]; @@ -1915,8 +1915,8 @@ void sk_applyConvertGesture(bContext *C, SK_Gesture *UNUSED(gest), SK_Sketch *sk static void sk_initGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch) { - gest->intersections.first = gest->intersections.last = NULL; - gest->self_intersections.first = gest->self_intersections.last = NULL; + BLI_listbase_clear(&gest->intersections); + BLI_listbase_clear(&gest->self_intersections); gest->segments = sk_createStroke(); gest->stk = sketch->gesture; @@ -2093,8 +2093,7 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch, } #if 0 - if (sketch->depth_peels.first != NULL) - { + if (BLI_listbase_is_empty(&sketch->depth_peels) == false) { float colors[8][3] = { {1, 0, 0}, {0, 1, 0}, diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c index 99f54de134a..d2d48fce8e6 100644 --- a/source/blender/editors/armature/pose_group.c +++ b/source/blender/editors/armature/pose_group.c @@ -399,7 +399,7 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) qsort(agrp_array, agrp_count, sizeof(tSortActionGroup), compare_agroup); /* create sorted bone group list from sorted array */ - pose->agroups.first = pose->agroups.last = NULL; + BLI_listbase_clear(&pose->agroups); for (i = 0; i < agrp_count; i++) { BLI_addtail(&pose->agroups, agrp_array[i].agrp); } diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 7a825b3805c..f77a3da06fb 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -1069,7 +1069,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) } /* check if any matches */ - if (pld->searchp.first == NULL) { + if (BLI_listbase_is_empty(&pld->searchp)) { pld->marker = NULL; return; } diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c index 014a64170db..380a3fffc6d 100644 --- a/source/blender/editors/armature/pose_utils.c +++ b/source/blender/editors/armature/pose_utils.c @@ -129,7 +129,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a /* if no PoseChannels were found, try a second pass, doing visible ones instead * i.e. if nothing selected, do whole pose */ - if (pfLinks->first == NULL) { + if (BLI_listbase_is_empty(pfLinks)) { CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { fcurves_to_pchan_links_get(pfLinks, ob, act, pchan); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 3c32f2a9eea..159fbb072f6 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1380,7 +1380,7 @@ static int separate_exec(bContext *C, wmOperator *op) /* 1. duplicate geometry and check for valid selection for separate */ adduplicateflagNurb(oldob, &newnurb, SELECT, true); - if (newnurb.first == NULL) { + if (BLI_listbase_is_empty(&newnurb)) { WM_cursor_wait(0); BKE_report(op->reports, RPT_ERROR, "Cannot separate current selection"); return OPERATOR_CANCELLED; @@ -1444,7 +1444,7 @@ static int curve_split_exec(bContext *C, wmOperator *op) adduplicateflagNurb(obedit, &newnurb, SELECT, true); - if (newnurb.first != NULL) { + if (BLI_listbase_is_empty(&newnurb) == false) { curve_delete_segments(obedit, true); BLI_movelisttolist(editnurb, &newnurb); @@ -2245,7 +2245,7 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb, nu = nu->prev; } - if (newnurb->first != NULL) { + if (BLI_listbase_is_empty(newnurb) == false) { cu->actnu = cu->actvert = CU_ACT_NONE; for (nu = newnurb->first; nu; nu = nu->next) { @@ -5915,7 +5915,7 @@ static int duplicate_exec(bContext *C, wmOperator *op) adduplicateflagNurb(obedit, &newnurb, SELECT, false); - if (newnurb.first != NULL) { + if (BLI_listbase_is_empty(&newnurb) == false) { BLI_movelisttolist(object_editcurve_get(obedit), &newnurb); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } @@ -6511,7 +6511,7 @@ int join_curve_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - tempbase.first = tempbase.last = NULL; + BLI_listbase_clear(&tempbase); /* trasnform all selected curves inverse in obact */ invert_m4_m4(imat, ob->obmat); diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index 9b7d691f081..8fcbee6f758 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -275,7 +275,7 @@ void free_gpcopybuf() { free_gpencil_layers(&gpcopybuf); - gpcopybuf.first = gpcopybuf.last = NULL; + BLI_listbase_clear(&gpcopybuf); gpcopy_firstframe = 999999999; } @@ -311,7 +311,7 @@ void copy_gpdata() gpls = (bGPDlayer *)ale->data; gpln = MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer"); - gpln->frames.first = gpln->frames.last = NULL; + BLI_listbase_clear(&gpln->frames); BLI_strncpy(gpln->info, gpls->info, sizeof(gpln->info)); BLI_addtail(&gpcopybuf, gpln); @@ -449,7 +449,7 @@ void paste_gpdata(Scene *scene) } /* if no strokes (i.e. new frame) added, free gpf */ - if (gpf->strokes.first == NULL) + if (BLI_listbase_is_empty(&gpf->strokes)) gpencil_layer_delframe(gpld, gpf); } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index a5376741ffd..94400682f9e 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1422,7 +1422,7 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG return; /* only convert if there are any strokes on this layer's frame to convert */ - if (gpf->strokes.first == NULL) + if (BLI_listbase_is_empty(&gpf->strokes)) return; /* initialize camera framing */ diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index 7edf723022f..136e9da389d 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -63,7 +63,7 @@ static bGPundonode *cur_node = NULL; int ED_gpencil_session_active(void) { - return undo_nodes.first != NULL; + return (BLI_listbase_is_empty(&undo_nodes) == false); } int ED_undo_gpencil_step(bContext *C, int step, const char *name) @@ -100,7 +100,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) free_gpencil_layers(&gpd->layers); /* copy layers */ - gpd->layers.first = gpd->layers.last = NULL; + BLI_listbase_clear(&gpd->layers); for (gpl = new_gpd->layers.first; gpl; gpl = gpl->next) { /* make a copy of source layer and its data */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index f85c53c7330..db2b804363c 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -252,7 +252,7 @@ void ui_bounds_block(uiBlock *block) uiBut *bt; int xof; - if (block->buttons.first == NULL) { + if (BLI_listbase_is_empty(&block->buttons)) { if (block->panel) { block->rect.xmin = 0.0; block->rect.xmax = block->panel->sizex; block->rect.ymin = 0.0; block->rect.ymax = block->panel->sizey; @@ -3535,7 +3535,7 @@ void uiBlockFlipOrder(uiBlock *block) } /* also flip order in block itself, for example for arrowkey */ - lb.first = lb.last = NULL; + BLI_listbase_clear(&lb); but = block->buttons.first; while (but) { next = but->next; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index cf930d635a7..b5d7bbd022a 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -542,7 +542,7 @@ static void ui_apply_but_funcs_after(bContext *C) /* copy to avoid recursive calls */ funcs = UIAfterFuncs; - UIAfterFuncs.first = UIAfterFuncs.last = NULL; + BLI_listbase_clear(&UIAfterFuncs); for (afterf = funcs.first; afterf; afterf = after.next) { after = *afterf; /* copy to avoid memleak on exit() */ @@ -7906,8 +7906,9 @@ static int ui_handler_region(bContext *C, const wmEvent *event, void *UNUSED(use ar = CTX_wm_region(C); retval = WM_UI_HANDLER_CONTINUE; - if (ar == NULL) return retval; - if (ar->uiblocks.first == NULL) return retval; + if (ar == NULL || BLI_listbase_is_empty(&ar->uiblocks)) { + return retval; + } /* either handle events for already activated button or try to activate */ but = ui_but_find_activated(ar); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 729cbc23efd..d7056d898cb 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -709,7 +709,7 @@ static void init_iconfile_list(struct ListBase *list) int totfile, i, index = 1; const char *icondir; - list->first = list->last = NULL; + BLI_listbase_clear(list); icondir = BLI_get_folder(BLENDER_DATAFILES, "icons"); if (icondir == NULL) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index e10baa35d0d..a2cbd0723c9 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2703,7 +2703,7 @@ static void ui_item_estimate(uiItem *item) for (subitem = litem->items.first; subitem; subitem = subitem->next) ui_item_estimate(subitem); - if (litem->items.first == NULL) + if (BLI_listbase_is_empty(&litem->items)) return; if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f) @@ -2793,7 +2793,7 @@ static void ui_item_layout(uiItem *item) if (item->type != ITEM_BUTTON) { uiLayout *litem = (uiLayout *)item; - if (litem->items.first == NULL) + if (BLI_listbase_is_empty(&litem->items)) return; if (litem->align) diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index aea004438f4..28f4940f236 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -1030,7 +1030,7 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op)) /* not essential but confuses users when there are keys with no data! * assume if they delete all data from the layer they also dont care about keys */ - if (masklay->splines.first == NULL) { + if (BLI_listbase_is_empty(&masklay->splines)) { BKE_mask_layer_free_shapes(masklay); } } diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index d24fbb3900e..a167870fdf6 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -262,7 +262,7 @@ static ListBase *knife_empty_list(KnifeTool_OpData *kcd) ListBase *lst; lst = BLI_memarena_alloc(kcd->arena, sizeof(ListBase)); - lst->first = lst->last = NULL; + BLI_listbase_clear(lst); return lst; } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 0078dd5ccaf..652095df781 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -2774,7 +2774,7 @@ static int edbm_select_ungrouped_poll(bContext *C) if ((em->selectmode & SCE_SELECT_VERTEX) == 0) { CTX_wm_operator_poll_msg_set(C, "Must be in vertex selection mode"); } - else if (obedit->defbase.first == NULL || cd_dvert_offset == -1) { + else if (BLI_listbase_is_empty(&obedit->defbase) || cd_dvert_offset == -1) { CTX_wm_operator_poll_msg_set(C, "No weights/vertex groups on object"); } else { diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 32a4adb11a6..a833c530711 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -131,7 +131,7 @@ static int mball_select_all_exec(bContext *C, wmOperator *op) MetaElem *ml; int action = RNA_enum_get(op->ptr, "action"); - if (mb->editelems->first == NULL) + if (BLI_listbase_is_empty(mb->editelems)) return OPERATOR_CANCELLED; if (action == SEL_TOGGLE) { @@ -702,7 +702,6 @@ static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe)) /* allocate memory for undo ListBase */ lb = MEM_callocN(sizeof(ListBase), "listbase undo"); - lb->first = lb->last = NULL; /* copy contents of current ListBase to the undo ListBase */ ml = editelems->first; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 025a7358d97..d52fd657397 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1299,7 +1299,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, ob->adt = NULL; ob->parent = NULL; - ob->constraints.first = ob->constraints.last = NULL; + BLI_listbase_clear(&ob->constraints); ob->curve_cache = NULL; ob->transflag &= ~OB_DUPLI; ob->lay = base->lay; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index c76b866bf2d..b8caf02fcd8 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1497,7 +1497,8 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED( ob = CTX_data_active_object(C); if (ob) { - const bool use_mode_particle_edit = (ob->particlesystem.first != NULL) || (ob->soft != NULL) || + const bool use_mode_particle_edit = (BLI_listbase_is_empty(&ob->particlesystem) == false) || + (ob->soft != NULL) || (modifiers_findByType(ob, eModifierType_Cloth) != NULL); while (input->identifier) { if ((input->value == OB_MODE_EDIT && OB_TYPE_SUPPORT_EDITMODE(ob->type)) || diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 2469737c76c..8d12809b0c2 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -523,7 +523,7 @@ static int lattice_select_ungrouped_exec(bContext *C, wmOperator *op) BPoint *bp; int a, tot; - if (obedit->defbase.first == NULL || lt->dvert == NULL) { + if (BLI_listbase_is_empty(&obedit->defbase) || lt->dvert == NULL) { BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index cd99fd34aac..013a6c78a15 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -313,7 +313,7 @@ static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, } if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) && - ob->particlesystem.first == NULL) + BLI_listbase_is_empty(&ob->particlesystem)) { ob->mode &= ~OB_MODE_PARTICLE_EDIT; } diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 1fce3213753..a1f447fbf50 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -467,7 +467,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) changed = object_select_all_by_dup_group(C, ob); } else if (nr == OBJECT_SELECT_LINKED_PARTICLE) { - if (ob->particlesystem.first == NULL) + if (BLI_listbase_is_empty(&ob->particlesystem)) return OPERATOR_CANCELLED; changed = object_select_all_by_particle(C, ob); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index fa47f8f8bd9..6f2af46fa92 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2814,7 +2814,7 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) ob->actdef = 1; /* remove all dverts */ - if (ob->defbase.first == NULL) { + if (BLI_listbase_is_empty(&ob->defbase)) { if (ob->type == OB_MESH) { Mesh *me = ob->data; CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert); @@ -2963,7 +2963,7 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) ob->actdef = 1; /* remove all dverts */ - if (ob->defbase.first == NULL) { + if (BLI_listbase_is_empty(&ob->defbase)) { if (ob->type == OB_MESH) { Mesh *me = ob->data; CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert); @@ -4057,7 +4057,7 @@ static int vertex_group_transfer_weight_exec(bContext *C, wmOperator *op) { if (ob_act != ob_src) { - if (ob_src->defbase.first == NULL) { + if (BLI_listbase_is_empty(&ob_src->defbase)) { BKE_reportf(op->reports, RPT_WARNING, "Skipping object '%s' it has no vertex groups", ob_src->id.name + 2); continue; @@ -4133,7 +4133,7 @@ static int vertex_group_transfer_weight_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } else { - if (op->reports->list.first == NULL) { + if (BLI_listbase_is_empty(&op->reports->list)) { BKE_report(op->reports, RPT_WARNING, "Failed, no other selected objects with vertex groups found"); } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 253a420b88a..d9ec0cf8416 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -227,7 +227,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); /* in the case of only one editable thing, set pset->edittype accordingly */ - if (pidlist.first && pidlist.first == pidlist.last) { + if (BLI_listbase_is_single(&pidlist)) { pid = pidlist.first; switch (pid->type) { case PTCACHE_TYPE_PARTICLES: @@ -4266,7 +4266,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, if (cache && cache->flag & PTCACHE_DISK_CACHE) return; - if (psys == NULL && (cache && cache->mem_cache.first == NULL)) + if (psys == NULL && (cache && BLI_listbase_is_empty(&cache->mem_cache))) return; edit = (psys) ? psys->edit : cache->edit; @@ -4285,7 +4285,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, psys->free_edit= PE_free_ptcache_edit; edit->pathcache = NULL; - edit->pathcachebufs.first = edit->pathcachebufs.last = NULL; + BLI_listbase_clear(&edit->pathcachebufs); pa = psys->particles; LOOP_POINTS { diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index b5607b42956..1a4f7c69bd7 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1447,7 +1447,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) break; /* old spacedata... happened during work on 2.50, remove */ - if (sl && sl->regionbase.first == NULL) { + if (sl && BLI_listbase_is_empty(&sl->regionbase)) { st->free(sl); BLI_freelinkN(&sa->spacedata, sl); if (slold == sl) { @@ -1460,7 +1460,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) /* swap regions */ slold->regionbase = sa->regionbase; sa->regionbase = sl->regionbase; - sl->regionbase.first = sl->regionbase.last = NULL; + BLI_listbase_clear(&sl->regionbase); /* put in front of list */ BLI_remlink(&sa->spacedata, sl); @@ -1476,7 +1476,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) if (slold) slold->regionbase = sa->regionbase; sa->regionbase = sl->regionbase; - sl->regionbase.first = sl->regionbase.last = NULL; + BLI_listbase_clear(&sl->regionbase); } } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 4674a5b36a3..86e78396fdf 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -500,7 +500,7 @@ static void screen_copy(bScreen *to, bScreen *from) BLI_duplicatelist(&to->vertbase, &from->vertbase); BLI_duplicatelist(&to->edgebase, &from->edgebase); BLI_duplicatelist(&to->areabase, &from->areabase); - to->regionbase.first = to->regionbase.last = NULL; + BLI_listbase_clear(&to->regionbase); s2 = to->vertbase.first; for (s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) { @@ -520,10 +520,10 @@ static void screen_copy(bScreen *to, bScreen *from) sa->v3 = sa->v3->newv; sa->v4 = sa->v4->newv; - sa->spacedata.first = sa->spacedata.last = NULL; - sa->regionbase.first = sa->regionbase.last = NULL; - sa->actionzones.first = sa->actionzones.last = NULL; - sa->handlers.first = sa->handlers.last = NULL; + BLI_listbase_clear(&sa->spacedata); + BLI_listbase_clear(&sa->regionbase); + BLI_listbase_clear(&sa->actionzones); + BLI_listbase_clear(&sa->handlers); area_copy_data(sa, saf, 0); } diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c index b4bd46376d3..fd8cc4df41e 100644 --- a/source/blender/editors/sculpt_paint/paint_undo.c +++ b/source/blender/editors/sculpt_paint/paint_undo.c @@ -191,7 +191,7 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char * } } else if (step == -1) { - if ((stack->current != NULL && stack->current->next == NULL) || stack->elems.first == NULL) { + if ((stack->current != NULL && stack->current->next == NULL) || BLI_listbase_is_empty(&stack->elems)) { /* pass */ } else { diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index dd414a7b2b2..e6efba4fa0c 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -41,6 +41,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLI_listbase.h" #include "BLI_rect.h" #include "BLF_translation.h" @@ -523,7 +524,7 @@ static int vert_select_ungrouped_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); Mesh *me = ob->data; - if ((ob->defbase.first == NULL) || (me->dvert == NULL)) { + if (BLI_listbase_is_empty(&ob->defbase) || (me->dvert == NULL)) { BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index d97eb223c3d..55296aeda18 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2183,7 +2183,7 @@ static bool wpaint_ensure_data(bContext *C, wmOperator *op) } } } - if (ob->defbase.first == NULL) { + if (BLI_listbase_is_empty(&ob->defbase)) { ED_vgroup_add(ob); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c index cf15fc3b2db..a04e15d3729 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c @@ -34,6 +34,7 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" +#include "BLI_listbase.h" #include "DNA_mesh_types.h" #include "DNA_object_types.h" @@ -175,7 +176,7 @@ static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle, DerivedMesh *dm; /* quick sanity check - we shouldn't have to run this if there are no modifiers */ - BLI_assert(ob->modifiers.first != NULL); + BLI_assert(BLI_listbase_is_empty(&ob->modifiers) == false); dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 975123f244c..eb992b65010 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -319,7 +319,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * ma = give_current_material(ob, ob->actcol); /* fill users */ - users->first = users->last = NULL; + BLI_listbase_clear(users); if (ma && !limited_mode) buttons_texture_users_find_nodetree(users, &ma->id, ma->nodetree, "Material"); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 5c8d1e84fd5..c4cbab4f230 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -122,8 +122,8 @@ static SpaceLink *console_duplicate(SpaceLink *sl) /* clear or remove stuff from old */ /* TODO - duplicate?, then we also need to duplicate the py namespace */ - sconsolen->scrollback.first = sconsolen->scrollback.last = NULL; - sconsolen->history.first = sconsolen->history.last = NULL; + BLI_listbase_clear(&sconsolen->scrollback); + BLI_listbase_clear(&sconsolen->history); return (SpaceLink *)sconsolen; } @@ -216,7 +216,7 @@ static void console_main_area_draw(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - if (sc->scrollback.first == NULL) + if (BLI_listbase_is_empty(&sc->scrollback)) WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL); /* clear and setup matrix */ diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 5e7a5690acd..ab69dc9e7b9 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -801,7 +801,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) /* No curve to modify/visualise the result? * => We still want to show the 1-1 default... */ - if ((fcu->totvert == 0) && (fcu->modifiers.first == NULL)) { + if ((fcu->totvert == 0) && BLI_listbase_is_empty(&fcu->modifiers)) { float t; /* draw with thin dotted lines in style of what curve would have been */ diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 68d82cd2848..93d103e11a6 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -430,7 +430,7 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op)) sipo = (SpaceIpo *)ac.sl; /* if no ghost curves, don't do anything */ - if (sipo->ghostCurves.first == NULL) + if (BLI_listbase_is_empty(&sipo->ghostCurves)) return OPERATOR_CANCELLED; /* free ghost curves */ diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 6df6b6bf0ff..a8beaadd711 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -1062,11 +1062,11 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches) short found = 0; /* abort if list is empty */ - if (matches->first == NULL) + if (BLI_listbase_is_empty(matches)) return NULL; /* if list only has 1 item, remove it from the list and return */ - if (matches->first == matches->last) { + if (BLI_listbase_is_single(matches)) { /* need to remove from the list, otherwise it gets freed and then we can't return it */ return BLI_pophead(matches); } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index dd302829f8e..f9539d44f2b 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -493,7 +493,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, if (rr == NULL || iuser == NULL) return; - if (rr->layers.first == NULL) { + if (BLI_listbase_is_empty(&rr->layers)) { uiItemL(row, IFACE_("No Layers in Render Result"), ICON_NONE); return; } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index e075ea09a59..bbc24004937 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1051,7 +1051,7 @@ static int image_open_exec(bContext *C, wmOperator *op) if (RNA_struct_property_is_set(op->ptr, "files") && RNA_struct_property_is_set(op->ptr, "directory")) { ListBase frames; - frames.first = frames.last = NULL; + BLI_listbase_clear(&frames); image_sequence_get_frames(op->ptr, &frames, path, sizeof(path)); frame_seq_len = image_sequence_get_len(&frames, &frame_ofs); BLI_freelistN(&frames); diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index c0e559a34cf..1f2fe6b1ecf 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -464,7 +464,7 @@ bool nlaedit_add_tracks_empty(bAnimContext *ac) BLI_assert(adt->flag & ADT_UI_SELECTED); /* ensure it is empty */ - if (adt->nla_tracks.first == NULL) { + if (BLI_listbase_is_empty(&adt->nla_tracks)) { /* add new track to this AnimData block then */ add_nlatrack(adt, NULL); added = true; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 37efd52f246..f54ceeeb702 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -121,7 +121,7 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op) ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* if no blocks, popup error? */ - if (anim_data.first == NULL) { + if (BLI_listbase_is_empty(&anim_data)) { BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweak mode for"); return OPERATOR_CANCELLED; } @@ -185,7 +185,7 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac) ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* if no blocks, popup error? */ - if (anim_data.first == NULL) { + if (BLI_listbase_is_empty(&anim_data)) { BKE_report(ac->reports, RPT_ERROR, "No AnimData blocks in tweak mode to exit from"); return false; } @@ -1304,7 +1304,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) /* special case: if there is only 1 island (i.e. temp meta BUT NOT unselected/normal/normal-meta strips) left after this, * and this island has two strips inside it, then we should be able to just swap these still... */ - if ((nlt->strips.first == nlt->strips.last) && (nlt->strips.first != NULL)) { + if (BLI_listbase_is_empty(&nlt->strips) == false) { NlaStrip *mstrip = (NlaStrip *)nlt->strips.first; if ((mstrip->flag & NLASTRIP_FLAG_TEMP_META) && (BLI_countlist(&mstrip->strips) == 2)) { diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index a1b1b453ee0..428495542c2 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -232,8 +232,9 @@ static int add_reroute_exec(bContext *C, wmOperator *op) node_deselect_all(snode); /* Find cut links and sort them by sockets */ - output_links.first = output_links.last = NULL; - input_links.first = input_links.last = NULL; + BLI_listbase_clear(&output_links); + BLI_listbase_clear(&input_links); + for (link = ntree->links.first; link; link = link->next) { if (nodeLinkIsHidden(link)) continue; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 9f76a9f1eb5..114b45ed174 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2002,7 +2002,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) clipboard_nodes_lb = BKE_node_clipboard_get_nodes(); clipboard_links_lb = BKE_node_clipboard_get_links(); - if (clipboard_nodes_lb->first == NULL) { + if (BLI_listbase_is_empty(clipboard_nodes_lb)) { BKE_report(op->reports, RPT_ERROR, "Clipboard is empty"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 31a9ec70660..3e1e605682f 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -274,7 +274,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode) bNodeSocket *sock; /* context check */ - if (tonode == NULL || tonode->outputs.first == NULL) + if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs)) return OPERATOR_CANCELLED; if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) return OPERATOR_CANCELLED; @@ -1209,7 +1209,7 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, return false; /* correct node */ - if (select->inputs.first == NULL || select->outputs.first == NULL) + if (BLI_listbase_is_empty(&select->inputs) || BLI_listbase_is_empty(&select->outputs)) return false; /* test node for links */ diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index ac0010b1d55..13a702e09c4 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -387,7 +387,7 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR]) else BLI_strncpy(node_name, node->typeinfo->ui_name, UI_MAX_NAME_STR); - if (node->inputs.first == NULL && + if (BLI_listbase_is_empty(&node->inputs) && node->outputs.first != node->outputs.last) { BLI_snprintf(name, UI_MAX_NAME_STR, "%s | %s", IFACE_(node_name), IFACE_(sock->link->fromsock->name)); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 2fe63c4b895..b8bb196b9c6 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -70,7 +70,7 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from) path_next = path->next; MEM_freeN(path); } - snode->treepath.first = snode->treepath.last = NULL; + BLI_listbase_clear(&snode->treepath); if (ntree) { path = MEM_callocN(sizeof(bNodeTreePath), "node tree path"); @@ -558,7 +558,7 @@ static SpaceLink *node_duplicate(SpaceLink *sl) BLI_duplicatelist(&snoden->treepath, &snode->treepath); /* clear or remove stuff from old */ - snoden->linkdrag.first = snoden->linkdrag.last = NULL; + BLI_listbase_clear(&snoden->linkdrag); /* Note: no need to set node tree user counts, * the editor only keeps at least 1 (id_us_ensure_real), diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index b4fdb1a5828..763f06bef21 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1422,7 +1422,7 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, TreeStoreElem *tselem; int y1, y2; - if (lb->first == NULL) return; + if (BLI_listbase_is_empty(lb)) return; y1 = y2 = *starty; /* for vertical lines between objects */ for (te = lb->first; te; te = te->next) { diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 036db3bae91..4231dc6f9f8 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1342,7 +1342,7 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob); } - lb->first = lb->last = NULL; + BLI_listbase_clear(lb); tp = tear; while (totelem--) { BLI_addtail(lb, tp->te); @@ -1443,7 +1443,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) } /* if there are still items in the list, that means that there were still some matches */ - return (lb->first != NULL); + return (BLI_listbase_is_empty(lb) == false); } static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeElement *te, Library *lib) diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 3a7d001f432..1f7415a3a56 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -451,7 +451,7 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl) SpaceOops *soutliner = (SpaceOops *)sl; SpaceOops *soutlinern = MEM_dupallocN(soutliner); - soutlinern->tree.first = soutlinern->tree.last = NULL; + BLI_listbase_clear(&soutlinern->tree); soutlinern->treestore = NULL; soutlinern->treehash = NULL; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index c032ecf6f8d..92d8a0ae066 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1980,7 +1980,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) Sequence *seq; - if (ed->metastack.first == NULL) + if (BLI_listbase_is_empty(&ed->metastack)) return OPERATOR_CANCELLED; ms = ed->metastack.last; @@ -2114,8 +2114,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) BLI_movelisttolist(ed->seqbasep, &last_seq->seqbase); - last_seq->seqbase.first = NULL; - last_seq->seqbase.last = NULL; + BLI_listbase_clear(&last_seq->seqbase); BLI_remlink(ed->seqbasep, last_seq); BKE_sequence_free(scene, last_seq); diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index ad761971200..09d51cf7afb 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -691,7 +691,7 @@ static SpaceLink *time_duplicate(SpaceLink *sl) SpaceTime *stime = (SpaceTime *)sl; SpaceTime *stimen = MEM_dupallocN(stime); - stimen->caches.first = stimen->caches.last = NULL; + BLI_listbase_clear(&stimen->caches); return (SpaceLink *)stimen; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 5a7c6172472..8a4714eeded 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -748,7 +748,7 @@ typedef struct ViewCachedString { void view3d_cached_text_draw_begin(void) { ListBase *strings = &CachedText[CachedTextLevel]; - strings->first = strings->last = NULL; + BLI_listbase_clear(strings); CachedTextLevel++; } @@ -4068,7 +4068,7 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3 if (BKE_mball_is_basis(ob)) { lb = &ob->curve_cache->disp; - if (lb->first == NULL) { + if (BLI_listbase_is_empty(lb)) { return true; } @@ -6584,7 +6584,7 @@ static void draw_object_matcap_check(View3D *v3d, Object *ob) v3d->defmaterial = MEM_mallocN(sizeof(Material), "matcap material"); *(v3d->defmaterial) = defmaterial; - v3d->defmaterial->gpumaterial.first = v3d->defmaterial->gpumaterial.last = NULL; + BLI_listbase_clear(&v3d->defmaterial->gpumaterial); v3d->defmaterial->preview = NULL; } /* first time users */ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index adedbc6277a..ab867472bdd 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2398,7 +2398,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) Base *base; Object *ob; - shadows.first = shadows.last = NULL; + BLI_listbase_clear(&shadows); /* update lamp transform and gather shadow lamps */ for (SETLOOPER(scene, sce_iter, base)) { diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 6aa34baeac6..8eb9c9be40b 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -857,7 +857,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->ctrl || /* weak - but user friendly */ - (ruler_info->items.first == NULL)) + BLI_listbase_is_empty(&ruler_info->items)) { View3D *v3d = CTX_wm_view3d(C); const bool use_depth = (v3d->drawtype >= OB_SOLID); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 150ac361291..eae4406990d 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1348,7 +1348,7 @@ static void SaveState(bContext *C, wmWindow *win) queue_back = win->queue; - win->queue.first = win->queue.last = NULL; + BLI_listbase_clear(&win->queue); //XXX waitcursor(1); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index cedbc4658b6..e4bc3f8d45a 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3051,11 +3051,11 @@ static void posttrans_gpd_clean(bGPdata *gpd) } /* error checking: it is unlikely, but may be possible to have none selected */ - if (sel_buffer.first == NULL) + if (BLI_listbase_is_empty(&sel_buffer)) continue; /* if all were selected (i.e. gpl->frames is empty), then just transfer sel-buf over */ - if (gpl->frames.first == NULL) { + if (BLI_listbase_is_empty(&gpl->frames)) { gpl->frames.first = sel_buffer.first; gpl->frames.last = sel_buffer.last; @@ -3141,11 +3141,11 @@ static void posttrans_mask_clean(Mask *mask) } /* error checking: it is unlikely, but may be possible to have none selected */ - if (sel_buffer.first == NULL) + if (BLI_listbase_is_empty(&sel_buffer)) continue; /* if all were selected (i.e. masklay->splines_shapes is empty), then just transfer sel-buf over */ - if (masklay->splines_shapes.first == NULL) { + if (BLI_listbase_is_empty(&masklay->splines_shapes)) { masklay->splines_shapes.first = sel_buffer.first; masklay->splines_shapes.last = sel_buffer.last; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 4499a9a03d2..e7b5add64db 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -719,7 +719,7 @@ void removeSnapPoint(TransInfo *t) if (t->tsnap.selectedPoint) { BLI_freelinkN(&t->tsnap.points, t->tsnap.selectedPoint); - if (t->tsnap.points.first == NULL) { + if (BLI_listbase_is_empty(&t->tsnap.points)) { t->tsnap.status &= ~MULTI_POINTS; } @@ -908,7 +908,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) float max_dist = FLT_MAX; float p[3] = {0.0f, 0.0f, 0.0f}; - depth_peels.first = depth_peels.last = NULL; + BLI_listbase_clear(&depth_peels); peelObjectsTransForm(t, &depth_peels, mval, t->tsnap.modeSelect); -- cgit v1.2.3