Fix T40010: Single user looses parent relationship (temporarily)

This commit is contained in:
Campbell Barton 2014-05-04 08:34:47 +10:00
parent ea6671a630
commit a1ba57a008
Notes: blender-bot 2023-02-14 10:42:33 +01:00
Referenced by issue #40023, Cycles Normal Bake problem
Referenced by issue #40010, When using link group to scene > make single user, armatures stop working temporarily.
2 changed files with 19 additions and 5 deletions

View File

@ -307,6 +307,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
Scene *scene = CTX_data_scene(C);
ED_object_single_user(bmain, scene, (struct Object *)id);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
DAG_relations_tag_update(bmain);
}
else {
if (id) {

View File

@ -2284,24 +2284,32 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C); /* ok if this is NULL */
int flag = RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */
bool copy_groups = false;
bool update_deps = false;
BKE_main_id_clear_newpoins(bmain);
if (RNA_boolean_get(op->ptr, "object"))
if (RNA_boolean_get(op->ptr, "object")) {
single_object_users(bmain, scene, v3d, flag, copy_groups);
if (RNA_boolean_get(op->ptr, "obdata"))
single_obdata_users(bmain, scene, flag);
/* needed since object relationships may have changed */
update_deps = true;
}
if (RNA_boolean_get(op->ptr, "material"))
if (RNA_boolean_get(op->ptr, "obdata")) {
single_obdata_users(bmain, scene, flag);
}
if (RNA_boolean_get(op->ptr, "material")) {
single_mat_users(scene, flag, RNA_boolean_get(op->ptr, "texture"));
}
#if 0 /* can't do this separate from materials */
if (RNA_boolean_get(op->ptr, "texture"))
single_mat_users(scene, flag, true);
#endif
if (RNA_boolean_get(op->ptr, "animation"))
if (RNA_boolean_get(op->ptr, "animation")) {
single_object_action_users(scene, flag);
}
/* TODO(sergey): This should not be needed, however some tool still could rely
* on the fact, that id->newid is kept NULL by default.
@ -2311,6 +2319,11 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
BKE_main_id_clear_newpoins(bmain);
WM_event_add_notifier(C, NC_WINDOW, NULL);
if (update_deps) {
DAG_relations_tag_update(bmain);
}
return OPERATOR_FINISHED;
}