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-05-13 13:54:09 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-05-13 15:12:10 +0300
commit5e0ec49570fa745c28bd028cb7796733a1d9dfce (patch)
tree67c920a9e00748d05a06cb770b027e685de50266 /source/blender/windowmanager/intern/wm_files_link.c
parent6276726bc4594f61753e51b8e877cf3c5018c808 (diff)
Fix T48416: Impossible to append from another file without localizing also all indirectly linked data.
Previous to 2.77, this used to be default behavior, was changed in rB591f4549c958b. However, in most append cases, you do want a full localization of your data, so this new behavior is kept by default, but there is now an option in append operator to only localize the 'first level' of data (i.e. datablocks from linked library itself, and not those from other 'sub-libraries').
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files_link.c')
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 5041eebd126..b5a8ff0c364 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -405,18 +405,38 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
/* BKE_main_unlock(bmain); */
- wm_link_append_data_free(lapp_data);
-
/* mark all library linked objects to be updated */
BKE_main_lib_objects_recalc_all(bmain);
IMB_colormanagement_check_file_config(bmain);
/* append, rather than linking */
if ((flag & FILE_LINK) == 0) {
- bool set_fake = RNA_boolean_get(op->ptr, "set_fake");
- BKE_library_make_local(bmain, NULL, true, set_fake);
+ const bool set_fake = RNA_boolean_get(op->ptr, "set_fake");
+ const bool do_recursive = RNA_boolean_get(op->ptr, "do_recursive");
+
+ if (do_recursive) {
+ BKE_library_make_local(bmain, NULL, true, set_fake);
+ }
+ else {
+ LinkNode *itemlink;
+ GSet *done_libraries = BLI_gset_new_ex(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp,
+ __func__, lapp_data->num_libraries);
+
+ for (itemlink = lapp_data->items.list; itemlink; itemlink = itemlink->next) {
+ ID *new_id = ((WMLinkAppendDataItem *)(itemlink->link))->new_id;
+
+ if (new_id && !BLI_gset_haskey(done_libraries, new_id->lib)) {
+ BKE_library_make_local(bmain, new_id->lib, true, set_fake);
+ BLI_gset_insert(done_libraries, new_id->lib);
+ }
+ }
+
+ BLI_gset_free(done_libraries, NULL);
+ }
}
+ wm_link_append_data_free(lapp_data);
+
/* important we unset, otherwise these object wont
* link into other scenes from this blend file */
BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false);
@@ -493,5 +513,8 @@ void WM_OT_append(wmOperatorType *ot)
FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
wm_link_append_properties_common(ot, false);
- RNA_def_boolean(ot->srna, "set_fake", false, "Fake User", "Set Fake User for appended items (except Objects and Groups)");
+ RNA_def_boolean(ot->srna, "set_fake", false, "Fake User",
+ "Set Fake User for appended items (except Objects and Groups)");
+ RNA_def_boolean(ot->srna, "do_recursive", true, "Localize All",
+ "Localize all appended data, including those indirectly linked from other libraries");
}