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:
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r--source/blender/blenkernel/intern/library.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index cda2030a9ee..61fea4ba2b5 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -341,7 +341,7 @@ void BKE_id_make_local_generic(Main *bmain, ID *id, const bool id_in_mainlist, c
ID *id_new;
/* Should not fail in expected usecases, but id_copy does not copy Scene e.g. */
- if (id_copy(bmain, id, &id_new, false)) {
+ if (id_copy(bmain, id, &id_new)) {
id_new->us = 0;
/* setting newid is mandatory for complex make_lib_local logic... */
@@ -538,6 +538,16 @@ static void id_copy_clear_runtime_pointers(ID *id, int UNUSED(flag))
}
}
+bool BKE_id_copy_is_allowed(const ID *id)
+{
+#define LIB_ID_TYPES_NOCOPY ID_LI, ID_SCR, ID_WM, /* Not supported */ \
+ ID_IP /* Deprecated */
+
+ return !ELEM(GS(id->name), LIB_ID_TYPES_NOCOPY);
+
+#undef LIB_ID_TYPES_NOCOPY
+}
+
/**
* Generic entry point for copying a datablock (new API).
*
@@ -550,24 +560,17 @@ static void id_copy_clear_runtime_pointers(ID *id, int UNUSED(flag))
* \param id: Source datablock.
* \param r_newid: Pointer to new (copied) ID pointer.
* \param flag: Set of copy options, see DNA_ID.h enum for details (leave to zero for default, full copy).
- * \param test: If set, do not do any copy, just test whether copy is supported.
* \return False when copying that ID type is not supported, true otherwise.
*/
-/* XXX TODO remove test thing, *all* IDs should be copyable that way! */
-bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, const bool test)
+bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
{
-#define LIB_ID_TYPES_NOCOPY ID_LI, ID_SCR, ID_WM, /* Not supported */ \
- ID_IP /* Deprecated */
-
- BLI_assert(test || (r_newid != NULL));
+ BLI_assert(r_newid != NULL);
/* Make sure destination pointer is all good. */
if ((flag & LIB_ID_CREATE_NO_ALLOCATE) == 0) {
- if (r_newid != NULL) {
- *r_newid = NULL;
- }
+ *r_newid = NULL;
}
else {
- if (r_newid != NULL && *r_newid != NULL) {
+ if (*r_newid != NULL) {
/* Allow some garbage non-initialized memory to go in, and clean it up here. */
const size_t size = BKE_libblock_get_alloc_info(GS(id->name), NULL);
memset(*r_newid, 0, size);
@@ -578,12 +581,9 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, con
if (id == NULL) {
return false;
}
- if (ELEM(GS(id->name), LIB_ID_TYPES_NOCOPY)) {
+ if (!BKE_id_copy_is_allowed(id)) {
return false;
}
- else if (test) {
- return true;
- }
BKE_libblock_copy_ex(bmain, id, r_newid, flag);
@@ -713,9 +713,9 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, con
* Invokes the appropriate copy method for the block and returns the result in
* newid, unless test. Returns true if the block can be copied.
*/
-bool id_copy(Main *bmain, const ID *id, ID **newid, bool test)
+bool id_copy(Main *bmain, const ID *id, ID **newid)
{
- return BKE_id_copy_ex(bmain, id, newid, LIB_ID_COPY_SHAPEKEY, test);
+ return BKE_id_copy_ex(bmain, id, newid, LIB_ID_COPY_SHAPEKEY);
}
/** Does a mere memory swap over the whole IDs data (including type-specific memory).
@@ -797,7 +797,7 @@ bool id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
/* if property isn't editable, we're going to have an extra block hanging around until we save */
if (RNA_property_editable(ptr, prop)) {
Main *bmain = CTX_data_main(C);
- if (id_copy(bmain, id, &newid, false) && newid) {
+ if (id_copy(bmain, id, &newid) && newid) {
/* copy animation actions too */
BKE_animdata_copy_id_action(bmain, id, false);
/* us is 1 by convention with new IDs, but RNA_property_pointer_set