static void id_local_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { if (tselem->id->lib && (tselem->id->flag & LIB_EXTERN)) { /* if the ID type has no special local function, * just clear the lib */ if (id_make_local(tselem->id, FALSE) == FALSE) { Main *bmain= CTX_data_main(C); id_clear_lib_data(bmain, tselem->id); } } }
void BKE_brush_make_local(Main *bmain, Brush *brush, const bool lib_local) { bool is_local = false, is_lib = false; /* - only lib users: do nothing (unless force_local is set) * - only local users: set flag * - mixed: make copy */ if (!ID_IS_LINKED_DATABLOCK(brush)) { return; } if (brush->clone.image) { /* Special case: ima always local immediately. Clone image should only have one user anyway. */ id_make_local(bmain, &brush->clone.image->id, false, false); } BKE_library_ID_test_usages(bmain, brush, &is_local, &is_lib); if (lib_local || is_local) { if (!is_lib) { id_clear_lib_data(bmain, &brush->id); BKE_id_expand_local(&brush->id); /* enable fake user by default */ id_fake_user_set(&brush->id); } else { Brush *brush_new = BKE_brush_copy(bmain, brush); /* Ensures FAKE_USER is set */ brush_new->id.us = 0; /* setting newid is mandatory for complex make_lib_local logic... */ ID_NEW_SET(brush, brush_new); if (!lib_local) { BKE_libblock_remap(bmain, brush, brush_new, ID_REMAP_SKIP_INDIRECT_USAGE); } } } }