Commit: 4569e19b83894218257e04976df34662fed7a381
Author: Bastien Montagne
Date: Mon Jul 11 16:41:59 2016 +0200
Branches: master
https://developer.blender.org/rB4569e19b83894218257e04976df34662fed7a381
Add generic 'BKE_id_expand_local' to BKE_library,
will be used by both make_local() and copy() datablock functions.
Note that this new func make 'extern' all IDs used by localized datablock,
not only refcounted ones as it used to be in each type's functions (with a few
exceptions).
===================================================================
M source/blender/blenkernel/BKE_library.h
M source/blender/blenkernel/intern/library.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_library.h
b/source/blender/blenkernel/BKE_library.h
index f3a0201..e633719 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 3dc7997..fc584e1 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)
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs