fix [#28178] make single user copy of object data doesn't work
This commit is contained in:
@@ -108,7 +108,7 @@ int ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op, fl
|
||||
struct Object *ED_object_add_type(struct bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer);
|
||||
|
||||
void ED_object_single_users(struct Main *bmain, struct Scene *scene, int full);
|
||||
|
||||
void ED_object_single_user(struct Scene *scene, struct Object *ob);
|
||||
|
||||
/* object motion paths */
|
||||
void ED_objects_clear_paths(struct bContext *C);
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "BKE_displist.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "ED_object.h"
|
||||
#include "ED_render.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
@@ -275,18 +276,28 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
|
||||
break;
|
||||
case UI_ID_ALONE:
|
||||
if(id) {
|
||||
/* make copy */
|
||||
if(id_copy(id, &newid, 0) && newid) {
|
||||
/* copy animation actions too */
|
||||
BKE_copy_animdata_id_action(id);
|
||||
/* us is 1 by convention, but RNA_property_pointer_set
|
||||
will also incremement it, so set it to zero */
|
||||
newid->us= 0;
|
||||
const int do_scene_obj= (GS(id->name) == ID_OB) &&
|
||||
(template->ptr.type == &RNA_SceneObjects);
|
||||
|
||||
/* assign copy */
|
||||
RNA_id_pointer_create(newid, &idptr);
|
||||
RNA_property_pointer_set(&template->ptr, template->prop, idptr);
|
||||
RNA_property_update(C, &template->ptr, template->prop);
|
||||
/* make copy */
|
||||
if(do_scene_obj) {
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
ED_object_single_user(scene, (struct Object *)id);
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
|
||||
}
|
||||
else {
|
||||
if(id_copy(id, &newid, 0) && newid) {
|
||||
/* copy animation actions too */
|
||||
BKE_copy_animdata_id_action(id);
|
||||
/* us is 1 by convention, but RNA_property_pointer_set
|
||||
will also incremement it, so set it to zero */
|
||||
newid->us= 0;
|
||||
|
||||
/* assign copy */
|
||||
RNA_id_pointer_create(newid, &idptr);
|
||||
RNA_property_pointer_set(&template->ptr, template->prop, idptr);
|
||||
RNA_property_update(C, &template->ptr, template->prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -404,10 +415,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
|
||||
|
||||
sprintf(str, "%d", id->us);
|
||||
|
||||
if(id->us<10)
|
||||
but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X,UI_UNIT_Y, NULL, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
|
||||
else
|
||||
but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X+10,UI_UNIT_Y, NULL, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
|
||||
but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
|
||||
|
||||
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE));
|
||||
if(!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib) || !editable)
|
||||
|
||||
@@ -1402,6 +1402,20 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag)
|
||||
set_sca_new_poins();
|
||||
}
|
||||
|
||||
/* not an especially efficient function, only added so the single user
|
||||
* button can be functional.*/
|
||||
void ED_object_single_user(Scene *scene, Object *ob)
|
||||
{
|
||||
Base *base;
|
||||
|
||||
for(base= FIRSTBASE; base; base= base->next) {
|
||||
if(base->object == ob) base->flag |= OB_DONE;
|
||||
else base->flag &= ~OB_DONE;
|
||||
}
|
||||
|
||||
single_object_users(scene, NULL, OB_DONE);
|
||||
}
|
||||
|
||||
static void new_id_matar(Material **matar, int totcol)
|
||||
{
|
||||
ID *id;
|
||||
|
||||
@@ -392,6 +392,7 @@ extern StructRNA RNA_Scene;
|
||||
extern StructRNA RNA_SceneGameData;
|
||||
extern StructRNA RNA_SceneRenderLayer;
|
||||
extern StructRNA RNA_SceneSequence;
|
||||
extern StructRNA RNA_SceneObjects;
|
||||
extern StructRNA RNA_Scopes;
|
||||
extern StructRNA RNA_Screen;
|
||||
extern StructRNA RNA_ScrewModifier;
|
||||
|
||||
Reference in New Issue
Block a user