IDManagement: refactor: Remove 'test' part from `BKE_lib_id_make_local`.

Mixing testing and actual action in a single function is just not a good
way to do things, and the 'testing' feature is not used anywhere
anymore, time to get rid of it.
This commit is contained in:
Bastien Montagne 2021-09-16 11:45:06 +02:00
parent 4f38624bf5
commit 236a9f0814
7 changed files with 22 additions and 30 deletions

View File

@ -248,7 +248,7 @@ enum {
};
void BKE_lib_id_make_local_generic(struct Main *bmain, struct ID *id, const int flags);
bool BKE_lib_id_make_local(struct Main *bmain, struct ID *id, const bool test, const int flags);
bool BKE_lib_id_make_local(struct Main *bmain, struct ID *id, const int flags);
bool id_single_user(struct bContext *C,
struct ID *id,
struct PointerRNA *ptr,

View File

@ -161,7 +161,7 @@ static void brush_make_local(Main *bmain, ID *id, const int flags)
if (brush->clone.image) {
/* Special case: ima always local immediately. Clone image should only have one user anyway. */
BKE_lib_id_make_local(bmain, &brush->clone.image->id, false, 0);
BKE_lib_id_make_local(bmain, &brush->clone.image->id, 0);
}
if (!force_local && !force_copy) {

View File

@ -480,10 +480,9 @@ void BKE_lib_id_make_local_generic(Main *bmain, ID *id, const int flags)
*
* \param flags: Special flag used when making a whole library's content local,
* it needs specific handling.
*
* \return true if the block can be made local.
* \return true is the ID has successfully been made local.
*/
bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags)
bool BKE_lib_id_make_local(Main *bmain, ID *id, const int flags)
{
const bool lib_local = (flags & LIB_ID_MAKELOCAL_FULL_LIBRARY) != 0;
@ -495,23 +494,21 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags
const IDTypeInfo *idtype_info = BKE_idtype_get_info_from_id(id);
if (idtype_info != NULL) {
if ((idtype_info->flags & IDTYPE_FLAGS_NO_LIBLINKING) == 0) {
if (!test) {
if (idtype_info->make_local != NULL) {
idtype_info->make_local(bmain, id, flags);
}
else {
BKE_lib_id_make_local_generic(bmain, id, flags);
}
}
return true;
}
if (idtype_info == NULL) {
BLI_assert_msg(0, "IDType Missing IDTypeInfo");
return false;
}
BLI_assert_msg(0, "IDType Missing IDTypeInfo");
return false;
BLI_assert((idtype_info->flags & IDTYPE_FLAGS_NO_LIBLINKING) == 0);
if (idtype_info->make_local != NULL) {
idtype_info->make_local(bmain, id, flags);
}
else {
BKE_lib_id_make_local_generic(bmain, id, flags);
}
return true;
}
struct IDCopyLibManagementData {
@ -2034,11 +2031,8 @@ void BKE_library_make_local(Main *bmain,
* Note that for objects, we don't want proxy pointers to be cleared yet. This will happen
* down the road in this function.
*/
BKE_lib_id_make_local(bmain,
id,
false,
LIB_ID_MAKELOCAL_FULL_LIBRARY |
LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING);
BKE_lib_id_make_local(
bmain, id, LIB_ID_MAKELOCAL_FULL_LIBRARY | LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING);
if (id->newid) {
if (GS(id->newid->name) == ID_OB) {

View File

@ -673,7 +673,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
}
}
else {
if (BKE_lib_id_make_local(bmain, id, false, 0)) {
if (BKE_lib_id_make_local(bmain, id, 0)) {
BKE_main_id_newptr_and_tag_clear(bmain);
/* Reassign to get proper updates/notifiers. */

View File

@ -739,7 +739,7 @@ static void id_local_fn(bContext *C,
Main *bmain = CTX_data_main(C);
/* if the ID type has no special local function,
* just clear the lib */
if (BKE_lib_id_make_local(bmain, tselem->id, false, 0) == false) {
if (!BKE_lib_id_make_local(bmain, tselem->id, 0)) {
BKE_lib_id_clear_library_data(bmain, tselem->id);
}
else {

View File

@ -931,8 +931,7 @@ static void rna_ID_user_remap(ID *id, Main *bmain, ID *new_id)
static struct ID *rna_ID_make_local(struct ID *self, Main *bmain, bool clear_proxy)
{
BKE_lib_id_make_local(
bmain, self, false, clear_proxy ? 0 : LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING);
BKE_lib_id_make_local(bmain, self, clear_proxy ? 0 : LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING);
ID *ret_id = self->newid ? self->newid : self;
BKE_id_clear_newpoin(self);

View File

@ -691,7 +691,7 @@ static void wm_append_do(WMLinkAppendData *lapp_data,
switch (item->append_action) {
case WM_APPEND_ACT_COPY_LOCAL: {
BKE_lib_id_make_local(
bmain, id, false, LIB_ID_MAKELOCAL_FULL_LIBRARY | LIB_ID_MAKELOCAL_FORCE_COPY);
bmain, id, LIB_ID_MAKELOCAL_FULL_LIBRARY | LIB_ID_MAKELOCAL_FORCE_COPY);
if (id->newid != NULL) {
if (GS(id->newid->name) == ID_OB) {
BKE_rigidbody_ensure_local_object(bmain, (Object *)id->newid);
@ -708,7 +708,6 @@ static void wm_append_do(WMLinkAppendData *lapp_data,
case WM_APPEND_ACT_MAKE_LOCAL:
BKE_lib_id_make_local(bmain,
id,
false,
LIB_ID_MAKELOCAL_FULL_LIBRARY | LIB_ID_MAKELOCAL_FORCE_LOCAL |
LIB_ID_MAKELOCAL_OBJECT_NO_PROXY_CLEARING);
BLI_assert(id->newid == NULL);