Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/blender_copybuffer.c
| Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * \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); | ||||
| SceneLayer *scene_layer = CTX_data_scene_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(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_scene_layer_base_deselect_all(scene_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, scene_layer); | BLO_library_link_end(mainl, &bh, flag, scene, view_layer); | ||||
| /* 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 | |||||