diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-06-29 08:34:20 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-06-29 08:34:20 +0400 |
commit | 2f60a5030f6c90c2278d3938460809de43012f85 (patch) | |
tree | fcf2b78b7a0c1e50cb613ad3219b94d06dc7f406 /source/blender/blenkernel/intern/library.c | |
parent | b85e0c3e850b8995577aee9b066e15e66c60bad3 (diff) |
Actions can now be made single-user from the Outliner
* Use the same method as from unlinking actions to do this.
* Split off the make single-user code used for the ID-browser into a
function in blenkernel which can be used elsewhere. Getting materials
to also work using this method proved to be a bit too tricky (due to
the whole messy ob vs obdata situation), so I haven't done that.
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 28 |
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 ) { |