[Bf-blender-cvs] [0256202] id-remap: Fix 'fromgroup' flag of objects/bases not being cleared correctly when unlinking group.
Bastien Montagne
noreply at git.blender.org
Wed Jun 22 12:27:55 CEST 2016
Commit: 025620231849cd43cd0584c1271f3c77924673c8
Author: Bastien Montagne
Date: Wed Jun 22 12:24:39 2016 +0200
Branches: id-remap
https://developer.blender.org/rB025620231849cd43cd0584c1271f3c77924673c8
Fix 'fromgroup' flag of objects/bases not being cleared correctly when unlinking group.
===================================================================
M source/blender/blenkernel/intern/library_remap.c
M source/blender/editors/space_outliner/outliner_tools.c
===================================================================
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 5e59427..4bde075 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -385,28 +385,62 @@ void BKE_libblock_remap_locked(
/* Some after-process updates.
* This is a bit ugly, but cannot see a way to avoid it. Maybe we should do a per-ID callback for this instead?
*/
- if (GS(old_id->name) == ID_OB) {
- Object *old_ob = (Object *)old_id;
- Object *new_ob = (Object *)new_id;
-
- if (old_ob->flag & OB_FROMGROUP) {
- /* Note that for Scene's BaseObject->flag, either we:
- * - unlinked old_ob (i.e. new_ob is NULL), in which case scenes' bases have been removed already.
- * - remaped old_ob by new_ob, in which case scenes' bases are still valid as is.
- * So in any case, no need to update them here. */
- if (BKE_group_object_find(NULL, old_ob) == NULL) {
- old_ob->flag &= ~OB_FROMGROUP;
- }
- if (new_ob == NULL) { /* We need to remove NULL-ified groupobjects... */
- Group *group;
- for (group = bmain->group.first; group; group = group->id.next) {
- BKE_group_object_unlink(group, NULL, NULL, NULL);
+ switch (GS(old_id->name)) {
+ case ID_OB:
+ {
+ Object *old_ob = (Object *)old_id;
+ Object *new_ob = (Object *)new_id;
+
+ if (old_ob->flag & OB_FROMGROUP) {
+ /* Note that for Scene's BaseObject->flag, either we:
+ * - unlinked old_ob (i.e. new_ob is NULL), in which case scenes' bases have been removed already.
+ * - remaped old_ob by new_ob, in which case scenes' bases are still valid as is.
+ * So in any case, no need to update them here. */
+ if (BKE_group_object_find(NULL, old_ob) == NULL) {
+ old_ob->flag &= ~OB_FROMGROUP;
+ }
+ if (new_ob == NULL) { /* We need to remove NULL-ified groupobjects... */
+ Group *group;
+ for (group = bmain->group.first; group; group = group->id.next) {
+ BKE_group_object_unlink(group, NULL, NULL, NULL);
+ }
+ }
+ else {
+ new_ob->flag |= OB_FROMGROUP;
}
}
- else {
- new_ob->flag |= OB_FROMGROUP;
- }
+ break;
}
+ case ID_GR:
+ if (new_id == NULL) { /* Only affects us in case group was unlinked. */
+ for (Scene *sce = bmain->scene.first; sce; sce = sce->id.next) {
+ /* Note that here we assume no object has no base (i.e. all objects are assumed instanced
+ * in one scene...). */
+ for (Base *base = sce->base.first; base; base = base->next) {
+ if (base->flag & OB_FROMGROUP) {
+ Object *ob = base->object;
+
+ if (ob->flag & OB_FROMGROUP) {
+ Group *grp = BKE_group_object_find(NULL, ob);
+
+ /* Unlinked group (old_id) is still in bmain... */
+ if (grp && (&grp->id == old_id)) {
+ grp = BKE_group_object_find(grp, ob);
+ }
+ if (!grp) {
+ ob->flag &= ~OB_FROMGROUP;
+ }
+ }
+ if (!(ob->flag & OB_FROMGROUP)) {
+ base->flag &= ~OB_FROMGROUP;
+ }
+ }
+ }
+ }
+ }
+ break;
+ default:
+ break;
}
/* Full rebuild of DAG! */
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index ba93dab..265df4a 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -1044,6 +1044,8 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op)
break;
case OL_GROUPOP_INSTANCE:
outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_instance_cb, NULL);
+ /* works without this except if you try render right after, see: 22027 */
+ DAG_relations_tag_update(CTX_data_main(C));
break;
case OL_GROUPOP_DELETE:
WM_operator_name_call(C, "OUTLINER_OT_id_delete", WM_OP_INVOKE_REGION_WIN, NULL);
@@ -1067,11 +1069,6 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op)
BLI_assert(0);
}
- if (event == 3) { /* instance */
- /* works without this except if you try render right after, see: 22027 */
- DAG_relations_tag_update(CTX_data_main(C));
- }
-
ED_undo_push(C, prop_group_op_types[event - 1].name);
WM_event_add_notifier(C, NC_GROUP, NULL);
More information about the Bf-blender-cvs
mailing list