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.h1
-rw-r--r--source/blender/blenkernel/intern/library.c27
2 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index f3a02019064..e63371900bf 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -84,6 +84,7 @@ bool id_make_local(struct Main *bmain, struct ID *id, bool test);
bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
bool id_copy(struct Main *bmain, struct ID *id, struct ID **newid, bool test);
void id_sort_by_name(struct ListBase *lb, struct ID *id);
+void BKE_id_expand_local(struct ID *id, const bool do_user_count);
bool new_id(struct ListBase *lb, struct ID *id, const char *name);
void id_clear_lib_data(struct Main *bmain, struct ID *id);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 3dc7997ca79..fc584e172a1 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -251,6 +251,33 @@ void id_fake_user_clear(ID *id)
}
}
+static int id_expand_local_callback(void *user_data, struct ID *UNUSED(id_self), struct ID **id_pointer, int cd_flag)
+{
+ const bool do_user_count = (user_data != NULL);
+
+ /* We tag all ID usages as extern, and increase usercount in case it was requested. */
+ if (*id_pointer) {
+ if (do_user_count && (cd_flag & IDWALK_USER)) {
+ id_us_plus(*id_pointer);
+ }
+ else {
+ id_lib_extern(*id_pointer);
+ }
+ }
+
+ return IDWALK_RET_NOP;
+}
+
+/**
+ * Expand ID usages of given id as 'extern' (and no more indirect) linked data. Used by ID copy/make_local functions.
+ *
+ * \param do_user_count If true, increase usercount of refcounted datablocks used by given id (use it with copied id).
+ */
+void BKE_id_expand_local(struct ID *id, const bool do_user_count)
+{
+ BKE_library_foreach_ID_link(id, id_expand_local_callback, SET_INT_IN_POINTER((int)do_user_count), 0);
+}
+
/* calls the appropriate make_local method for the block, unless test. Returns true
* if the block can be made local. */
bool id_make_local(Main *bmain, ID *id, bool test)