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:
authorBastien Montagne <montagne29@wanadoo.fr>2016-06-22 19:05:55 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-06-22 19:05:55 +0300
commit7547c6a250cd6f36c9894605b822380a1261febf (patch)
tree1b68ea4b2ac56927a212f10cd5d491a581e366c0 /source/blender/makesrna/intern/rna_ID.c
parentfb1f7fad78e4a0a1220c7472e1332043b2ee0f85 (diff)
ID-Remap, step two: add some user-level tools.
This commit adds operators and Outliner menu entries to reload or relocate a library, and to delete or replace a datablock. RNA ID API is also extended to allow ID deletion and remapping from python. Review task: D2027 (https://developer.blender.org/D2027). Reviewed by campbellbarton, thanks a bunch.
Diffstat (limited to 'source/blender/makesrna/intern/rna_ID.c')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index de793054ca7..92f4d1ac07b 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -87,10 +87,13 @@ EnumPropertyItem rna_enum_id_type_items[] = {
#include "DNA_anim_types.h"
+#include "BLI_listbase.h"
+
#include "BKE_font.h"
#include "BKE_idprop.h"
#include "BKE_library.h"
#include "BKE_library_query.h"
+#include "BKE_library_remap.h"
#include "BKE_animsys.h"
#include "BKE_material.h"
#include "BKE_depsgraph.h"
@@ -333,6 +336,19 @@ static void rna_ID_user_clear(ID *id)
id->us = 0; /* don't save */
}
+static void rna_ID_delete(ID *id, Main *bmain)
+{
+ BKE_libblock_delete(bmain, id);
+}
+
+static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
+{
+ if (GS(id->name) == GS(new_id->name)) {
+ /* For now, do not allow remapping data in linked data from here... */
+ BKE_libblock_remap(bmain, id, new_id, ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_NEVER_NULL_USAGE);
+ }
+}
+
static AnimData * rna_ID_animation_data_create(ID *id, Main *bmain)
{
AnimData *adt = BKE_animdata_add_id(id);
@@ -973,10 +989,20 @@ static void rna_def_ID(BlenderRNA *brna)
parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
RNA_def_function_return(func, parm);
+ func = RNA_def_function(srna, "destroy", "rna_ID_delete");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
+ RNA_def_function_ui_description(func, "Delete this ID from Blender (WARNING: no undo, do not use it after calling this!)");
+
func = RNA_def_function(srna, "user_clear", "rna_ID_user_clear");
RNA_def_function_ui_description(func, "Clear the user count of a data-block so its not saved, "
"on reload the data will be removed");
+ func = RNA_def_function(srna, "user_remap", "rna_ID_user_remap");
+ RNA_def_function_ui_description(func, "Replace all usage in the .blend file of this ID by new given one");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
+ parm = RNA_def_pointer(func, "new_id", "ID", "", "New ID to use");
+ RNA_def_property_flag(parm, PROP_NEVER_NULL);
+
func = RNA_def_function(srna, "user_of_id", "BKE_library_ID_use_ID");
RNA_def_function_ui_description(func, "Count the number of times that ID uses/references given one");
parm = RNA_def_pointer(func, "id", "ID", "", "ID to count usages");