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:
-rw-r--r--source/blender/blenkernel/BKE_library.h3
-rw-r--r--source/blender/blenkernel/intern/library.c11
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c33
3 files changed, 38 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 21585a160dd..2215fbfbd7d 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -119,7 +119,8 @@ void BKE_main_lib_objects_recalc_all(struct Main *bmain);
/* (MAX_ID_NAME - 2) + 3 */
void BKE_id_ui_prefix(char name[66 + 1], const struct ID *id);
-void BKE_library_make_local(struct Main *bmain, struct Library *lib, bool untagged_only, bool set_fake);
+void BKE_library_make_local(
+ struct Main *bmain, const struct Library *lib, const bool untagged_only, const bool set_fake);
typedef void (*BKE_library_free_window_manager_cb)(struct bContext *, struct wmWindowManager *);
typedef void (*BKE_library_free_notifier_reference_cb)(const void *);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 9e81cded9f5..0a681a75f84 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1830,9 +1830,14 @@ static void lib_indirect_test_id(ID *id, Library *lib)
#undef LIBTAG
}
-/* if lib!=NULL, only all from lib local
- * bmain is almost certainly G.main */
-void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only, bool set_fake)
+/** Make linked datablocks local.
+ *
+ * \param bmain Almost certainly G.main.
+ * \param lib If not NULL, only make local datablocks from this library.
+ * \param untagged_only If true, only make local datablocks not tagged with LIB_TAG_PRE_EXISTING.
+ * \param set_fake If true, set fake user on all localized datablocks (except group and objects ones).
+ */
+void BKE_library_make_local(Main *bmain, const Library *lib, const bool untagged_only, const bool set_fake)
{
ListBase *lbarray[MAX_LIBARRAY];
ID *id, *idn;
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");
}