Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/intern/bpy_library_load.c
| Show First 20 Lines • Show All 326 Lines • ▼ Show 20 Lines | static void bpy_lib_exit_warn_type(BPy_Library *self, PyObject *item) | ||||
| PyErr_Restore(exc, val, tb); | PyErr_Restore(exc, val, tb); | ||||
| } | } | ||||
| static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) | static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(BPy_GetContext()); | Main *bmain = CTX_data_main(BPy_GetContext()); | ||||
| Main *mainl = NULL; | Main *mainl = NULL; | ||||
| int err = 0; | int err = 0; | ||||
| const bool do_append = ((self->flag & FILE_LINK) == 0); | |||||
| 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, &(self->blo_handle), self->relpath); | mainl = BLO_library_link_begin(bmain, &(self->blo_handle), self->relpath); | ||||
| { | { | ||||
| int idcode_step = 0, idcode; | int idcode_step = 0, idcode; | ||||
| while ((idcode = BKE_idcode_iter_step(&idcode_step))) { | while ((idcode = BKE_idcode_iter_step(&idcode_step))) { | ||||
| if (BKE_idcode_is_linkable(idcode)) { | if (BKE_idcode_is_linkable(idcode) && (idcode != ID_WS || do_append)) { | ||||
| const char *name_plural = BKE_idcode_to_name_plural(idcode); | const char *name_plural = BKE_idcode_to_name_plural(idcode); | ||||
| PyObject *ls = PyDict_GetItemString(self->dict, name_plural); | PyObject *ls = PyDict_GetItemString(self->dict, name_plural); | ||||
| // printf("lib: %s\n", name_plural); | // printf("lib: %s\n", name_plural); | ||||
| if (ls && PyList_Check(ls)) { | if (ls && PyList_Check(ls)) { | ||||
| /* loop */ | /* loop */ | ||||
| Py_ssize_t size = PyList_GET_SIZE(ls); | Py_ssize_t size = PyList_GET_SIZE(ls); | ||||
| Py_ssize_t i; | Py_ssize_t i; | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | else { | ||||
| GHash *old_to_new_ids = BLI_ghash_ptr_new(__func__); | GHash *old_to_new_ids = BLI_ghash_ptr_new(__func__); | ||||
| /* copied from wm_operator.c */ | /* copied from wm_operator.c */ | ||||
| { | { | ||||
| /* 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); | ||||
| /* append, rather than linking */ | /* append, rather than linking */ | ||||
| if ((self->flag & FILE_LINK) == 0) { | if (do_append) { | ||||
| BKE_library_make_local(bmain, lib, old_to_new_ids, true, false); | BKE_library_make_local(bmain, lib, old_to_new_ids, true, false); | ||||
| } | } | ||||
| } | } | ||||
| BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false); | BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, false); | ||||
| /* finally swap the capsules for real bpy objects | /* finally swap the capsules for real bpy objects | ||||
| * important since BLO_library_append_end initializes NodeTree types used by srna->refine */ | * important since BLO_library_append_end initializes NodeTree types used by srna->refine */ | ||||
| #ifdef USE_RNA_DATABLOCKS | #ifdef USE_RNA_DATABLOCKS | ||||
| { | { | ||||
| int idcode_step = 0, idcode; | int idcode_step = 0, idcode; | ||||
| while ((idcode = BKE_idcode_iter_step(&idcode_step))) { | while ((idcode = BKE_idcode_iter_step(&idcode_step))) { | ||||
| if (BKE_idcode_is_linkable(idcode)) { | if (BKE_idcode_is_linkable(idcode) && (idcode != ID_WS || do_append)) { | ||||
| const char *name_plural = BKE_idcode_to_name_plural(idcode); | const char *name_plural = BKE_idcode_to_name_plural(idcode); | ||||
| PyObject *ls = PyDict_GetItemString(self->dict, name_plural); | PyObject *ls = PyDict_GetItemString(self->dict, name_plural); | ||||
| if (ls && PyList_Check(ls)) { | if (ls && PyList_Check(ls)) { | ||||
| Py_ssize_t size = PyList_GET_SIZE(ls); | Py_ssize_t size = PyList_GET_SIZE(ls); | ||||
| Py_ssize_t i; | Py_ssize_t i; | ||||
| PyObject *item; | PyObject *item; | ||||
| for (i = 0; i < size; i++) { | for (i = 0; i < size; i++) { | ||||
| ▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines | |||||