Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r--source/blender/blenkernel/intern/library.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 0b07f40cad6..5dbe35b2f7d 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -368,6 +368,34 @@ int id_unlink(ID *id, int test)
return 0;
}
+int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
+{
+ ID *newid = NULL;
+ PointerRNA idptr;
+
+ if (id) {
+ /* if property isn't editable, we're going to have an extra block hanging around until we save */
+ if (RNA_property_editable(ptr, prop)) {
+ 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(ptr, prop, idptr);
+ RNA_property_update(C, ptr, prop);
+
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
ListBase *which_libbase(Main *mainlib, short type)
{
switch( type ) {