Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_files_link.c
| Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | static WMLinkAppendDataItem *wm_link_append_data_item_add( | ||||
| BLI_linklist_append_arena(&lapp_data->items, item, lapp_data->memarena); | BLI_linklist_append_arena(&lapp_data->items, item, lapp_data->memarena); | ||||
| lapp_data->num_items++; | lapp_data->num_items++; | ||||
| return item; | return item; | ||||
| } | } | ||||
| static void wm_link_do( | static void wm_link_do( | ||||
| WMLinkAppendData *lapp_data, ReportList *reports, Main *bmain, Scene *scene, ViewLayer *view_layer) | WMLinkAppendData *lapp_data, ReportList *reports, | ||||
| Main *bmain, Scene *scene, ViewLayer *view_layer, | |||||
| WorkSpace *workspace) | |||||
| { | { | ||||
| Main *mainl; | Main *mainl; | ||||
| BlendHandle *bh; | BlendHandle *bh; | ||||
| Library *lib; | Library *lib; | ||||
| const int flag = lapp_data->flag; | const int flag = lapp_data->flag; | ||||
| LinkNode *liblink, *itemlink; | LinkNode *liblink, *itemlink; | ||||
| Show All 40 Lines | for (item_idx = 0, itemlink = lapp_data->items.list; itemlink; item_idx++, itemlink = itemlink->next) { | ||||
| if (new_id) { | if (new_id) { | ||||
| /* If the link is successful, clear item's libs 'todo' flags. | /* If the link is successful, clear item's libs 'todo' flags. | ||||
| * This avoids trying to link same item with other libraries to come. */ | * This avoids trying to link same item with other libraries to come. */ | ||||
| BLI_BITMAP_SET_ALL(item->libraries, false, lapp_data->num_libraries); | BLI_BITMAP_SET_ALL(item->libraries, false, lapp_data->num_libraries); | ||||
| item->new_id = new_id; | item->new_id = new_id; | ||||
| } | } | ||||
| } | } | ||||
| BLO_library_link_end(mainl, &bh, flag, scene, view_layer); | BLO_library_link_end(mainl, &bh, flag, scene, view_layer, workspace); | ||||
| BLO_blendhandle_close(bh); | BLO_blendhandle_close(bh); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Check if an item defined by \a name and \a group can be appended/linked. | * Check if an item defined by \a name and \a group can be appended/linked. | ||||
| * | * | ||||
| * \param reports: Optionally report an error when an item can't be appended/linked. | * \param reports: Optionally report an error when an item can't be appended/linked. | ||||
| ▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | static int wm_link_append_exec(bContext *C, wmOperator *op) | ||||
| if (!has_item) { | if (!has_item) { | ||||
| wm_link_append_data_free(lapp_data); | wm_link_append_data_free(lapp_data); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* XXX We'd need re-entrant locking on Main for this to work... */ | /* XXX We'd need re-entrant locking on Main for this to work... */ | ||||
| /* BKE_main_lock(bmain); */ | /* BKE_main_lock(bmain); */ | ||||
| wm_link_do(lapp_data, op->reports, bmain, scene, view_layer); | wm_link_do(lapp_data, op->reports, bmain, scene, view_layer, CTX_wm_workspace(C)); | ||||
| /* BKE_main_unlock(bmain); */ | /* BKE_main_unlock(bmain); */ | ||||
| /* mark all library linked objects to be updated */ | /* mark all library linked objects to be updated */ | ||||
| BKE_main_lib_objects_recalc_all(bmain); | BKE_main_lib_objects_recalc_all(bmain); | ||||
| IMB_colormanagement_check_file_config(bmain); | IMB_colormanagement_check_file_config(bmain); | ||||
| /* append, rather than linking */ | /* append, rather than linking */ | ||||
| ▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | #endif | ||||
| if (!has_item) { | if (!has_item) { | ||||
| /* nothing to relocate */ | /* nothing to relocate */ | ||||
| return; | return; | ||||
| } | } | ||||
| BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, true); | BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, true); | ||||
| /* We do not want any instanciation here! */ | /* We do not want any instanciation here! */ | ||||
| wm_link_do(lapp_data, reports, bmain, NULL, NULL); | wm_link_do(lapp_data, reports, bmain, NULL, NULL, NULL); | ||||
| BKE_main_lock(bmain); | BKE_main_lock(bmain); | ||||
| /* We add back old id to bmain. | /* We add back old id to bmain. | ||||
| * We need to do this in a first, separated loop, otherwise some of those may not be handled by | * We need to do this in a first, separated loop, otherwise some of those may not be handled by | ||||
| * ID remapping, which means they would still reference old data to be deleted... */ | * ID remapping, which means they would still reference old data to be deleted... */ | ||||
| for (item_idx = 0, itemlink = lapp_data->items.list; itemlink; item_idx++, itemlink = itemlink->next) { | for (item_idx = 0, itemlink = lapp_data->items.list; itemlink; item_idx++, itemlink = itemlink->next) { | ||||
| WMLinkAppendDataItem *item = itemlink->link; | WMLinkAppendDataItem *item = itemlink->link; | ||||
| ▲ Show 20 Lines • Show All 335 Lines • Show Last 20 Lines | |||||