Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/blender_copybuffer.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | bool BKE_copybuffer_read(Main *bmain_dst, const char *libname, ReportList *reports) | ||||
| BlendHandle *bh = BLO_blendhandle_from_file(libname, reports); | BlendHandle *bh = BLO_blendhandle_from_file(libname, reports); | ||||
| if (bh == NULL) { | if (bh == NULL) { | ||||
| /* Error reports will have been made by BLO_blendhandle_from_file(). */ | /* Error reports will have been made by BLO_blendhandle_from_file(). */ | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* Here appending/linking starts. */ | /* Here appending/linking starts. */ | ||||
| Main *mainl = BLO_library_link_begin(bmain_dst, &bh, libname); | Main *mainl = BLO_library_link_begin(bmain_dst, &bh, libname); | ||||
| BLO_library_link_copypaste(mainl, bh); | BLO_library_link_copypaste(mainl, bh); | ||||
| BLO_library_link_end(mainl, &bh, 0, NULL, NULL); | BLO_library_link_end(mainl, &bh, 0, NULL, NULL, NULL); | ||||
| /* Mark all library linked objects to be updated. */ | /* Mark all library linked objects to be updated. */ | ||||
| BKE_main_lib_objects_recalc_all(bmain_dst); | BKE_main_lib_objects_recalc_all(bmain_dst); | ||||
| IMB_colormanagement_check_file_config(bmain_dst); | IMB_colormanagement_check_file_config(bmain_dst); | ||||
| /* Append, rather than linking. */ | /* Append, rather than linking. */ | ||||
| Library *lib = BLI_findstring(&bmain_dst->library, libname, offsetof(Library, filepath)); | Library *lib = BLI_findstring(&bmain_dst->library, libname, offsetof(Library, filepath)); | ||||
| BKE_library_make_local(bmain_dst, lib, NULL, true, false); | BKE_library_make_local(bmain_dst, lib, NULL, true, false); | ||||
| /* Important we unset, otherwise these object wont | /* Important we unset, otherwise these object wont | ||||
| * link into other scenes from this blend file. | * link into other scenes from this blend file. | ||||
| */ | */ | ||||
| BKE_main_id_tag_all(bmain_dst, LIB_TAG_PRE_EXISTING, false); | BKE_main_id_tag_all(bmain_dst, LIB_TAG_PRE_EXISTING, false); | ||||
| BLO_blendhandle_close(bh); | BLO_blendhandle_close(bh); | ||||
| return true; | return true; | ||||
| } | } | ||||
| /** | /** | ||||
| * \return Success. | * \return Success. | ||||
| */ | */ | ||||
| bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, ReportList *reports) | bool BKE_copybuffer_paste(bContext *C, const char *libname, const short flag, ReportList *reports) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| struct WorkSpace *workspace = CTX_wm_workspace(C); | |||||
| Main *mainl = NULL; | Main *mainl = NULL; | ||||
| Library *lib; | Library *lib; | ||||
| BlendHandle *bh; | BlendHandle *bh; | ||||
| bh = BLO_blendhandle_from_file(libname, reports); | bh = BLO_blendhandle_from_file(libname, reports); | ||||
| if (bh == NULL) { | if (bh == NULL) { | ||||
| /* error reports will have been made by BLO_blendhandle_from_file() */ | /* error reports will have been made by BLO_blendhandle_from_file() */ | ||||
| return false; | return false; | ||||
| } | } | ||||
| BKE_view_layer_base_deselect_all(view_layer); | BKE_view_layer_base_deselect_all(view_layer); | ||||
| /* tag everything, all untagged data can be made local | /* tag everything, all untagged data can be made local | ||||
| * its also generally useful to know what is new | * its also generally useful to know what is new | ||||
| * | * | ||||
| * take extra care BKE_main_id_flag_all(bmain, LIB_TAG_PRE_EXISTING, false) is called after! */ | * take extra care BKE_main_id_flag_all(bmain, LIB_TAG_PRE_EXISTING, false) is called after! */ | ||||
| BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, true); | BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, true); | ||||
| /* here appending/linking starts */ | /* here appending/linking starts */ | ||||
| mainl = BLO_library_link_begin(bmain, &bh, libname); | mainl = BLO_library_link_begin(bmain, &bh, libname); | ||||
| BLO_library_link_copypaste(mainl, bh); | BLO_library_link_copypaste(mainl, bh); | ||||
| BLO_library_link_end(mainl, &bh, flag, scene, view_layer); | BLO_library_link_end(mainl, &bh, flag, scene, view_layer, workspace); | ||||
| /* 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 */ | ||||
| lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath)); | lib = BLI_findstring(&bmain->library, libname, offsetof(Library, filepath)); | ||||
| BKE_library_make_local(bmain, lib, NULL, true, false); | BKE_library_make_local(bmain, lib, NULL, true, false); | ||||
| Show All 19 Lines | |||||