diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index c764ee22162..03a1086050f 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -434,33 +434,37 @@ static int group_link_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Object *ob = ED_object_context(C); Group *group = BLI_findlink(&bmain->group, RNA_enum_get(op->ptr, "group")); - if (ELEM(NULL, ob, group)) + if (!group) { return OPERATOR_CANCELLED; - - /* Early return check, if the object is already in group - * we could skip all the dependency check and just consider - * operator is finished. - */ - if (BKE_group_object_exists(group, ob)) { - return OPERATOR_FINISHED; } - /* Adding object to group which is used as dupligroup for self is bad idea. - * - * It is also bad idea to add object to group which is in group which - * contains our current object. - */ - if (BKE_group_object_cyclic_check(bmain, ob, group)) { - BKE_report(op->reports, RPT_ERROR, "Could not add the group because of dependency cycle detected"); - return OPERATOR_CANCELLED; - } + CTX_DATA_BEGIN(C, Object *, ob_iter, selected_objects) { + /* Early return check, if the object is already in group + * we could skip all the dependency check and just continue + */ + if (BKE_group_object_exists(group, ob_iter)) { + continue; + } - BKE_group_object_add(group, ob, scene, NULL); + /* Adding object to group which is used as dupligroup for self is bad idea. + * + * It is also bad idea to add object to group which is in group which + * contains our current object. + */ + if (BKE_group_object_cyclic_check(bmain, ob_iter, group)) { + char message[132]; + sprintf(message, "Could not add '%s' to the group because of dependency cycle detected", ob_iter->id.name); + BKE_report(op->reports, RPT_WARNING, message); + continue; + } - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + BKE_group_object_add(group, ob_iter, scene, NULL); + + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter); + } + CTX_DATA_END; return OPERATOR_FINISHED; }