Cleanup in BLO API: rename 'append' funcs to 'link', since none do append, but only linking of datablocks!
This commit is contained in:
parent
6af043424d
commit
4bc08d09ae
|
@ -1069,11 +1069,11 @@ int BKE_copybuffer_paste(bContext *C, const char *libname, ReportList *reports)
|
|||
BKE_main_id_flag_all(bmain, LIB_PRE_EXISTING, true);
|
||||
|
||||
/* here appending/linking starts */
|
||||
mainl = BLO_library_append_begin(bmain, &bh, libname);
|
||||
mainl = BLO_library_link_begin(bmain, &bh, libname);
|
||||
|
||||
BLO_library_append_all(mainl, bh);
|
||||
BLO_library_link_all(mainl, bh);
|
||||
|
||||
BLO_library_append_end(C, mainl, &bh, 0, 0);
|
||||
BLO_library_link_end(C, mainl, &bh, 0, 0);
|
||||
|
||||
/* mark all library linked objects to be updated */
|
||||
BKE_main_lib_objects_recalc_all(bmain);
|
||||
|
|
|
@ -213,13 +213,13 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha
|
|||
* \param filepath Used for relative linking, copied to the lib->name
|
||||
* \return the library Main, to be passed to BLO_library_append_named_part as mainl.
|
||||
*/
|
||||
struct Main *BLO_library_append_begin(
|
||||
struct Main *BLO_library_link_begin(
|
||||
struct Main *mainvar, BlendHandle **bh,
|
||||
const char *filepath);
|
||||
|
||||
|
||||
/**
|
||||
* Link/Append a named datablock from an external blend file.
|
||||
* Link a named datablock from an external blend file.
|
||||
*
|
||||
* \param mainl The main database to link from (not the active one).
|
||||
* \param bh The blender file handle.
|
||||
|
@ -227,13 +227,13 @@ struct Main *BLO_library_append_begin(
|
|||
* \param idcode The kind of datablock to link.
|
||||
* \return the appended ID when found.
|
||||
*/
|
||||
struct ID *BLO_library_append_named_part(
|
||||
struct ID *BLO_library_link_named_part(
|
||||
struct Main *mainl, BlendHandle **bh,
|
||||
const char *idname, const int idcode);
|
||||
|
||||
/**
|
||||
* Link/Append a named datablock from an external blend file.
|
||||
* optionally instance the object in the scene when the flags are set.
|
||||
* Link a named datablock from an external blend file.
|
||||
* optionally instantiate the object/group in the scene when the flags are set.
|
||||
*
|
||||
* \param C The context, when NULL instancing object in the scene isn't done.
|
||||
* \param mainl The main database to link from (not the active one).
|
||||
|
@ -243,13 +243,13 @@ struct ID *BLO_library_append_named_part(
|
|||
* \param flag Options for linking, used for instancing.
|
||||
* \return the appended ID when found.
|
||||
*/
|
||||
struct ID *BLO_library_append_named_part_ex(
|
||||
struct ID *BLO_library_link_named_part_ex(
|
||||
const struct bContext *C, struct Main *mainl, BlendHandle **bh,
|
||||
const char *idname, const int idcode, const short flag);
|
||||
|
||||
void BLO_library_append_end(const struct bContext *C, struct Main *mainl, BlendHandle **bh, int idcode, short flag);
|
||||
void BLO_library_link_end(const struct bContext *C, struct Main *mainl, BlendHandle **bh, int idcode, short flag);
|
||||
|
||||
void BLO_library_append_all(struct Main *mainl, BlendHandle *bh);
|
||||
void BLO_library_link_all(struct Main *mainl, BlendHandle *bh);
|
||||
|
||||
void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
|
||||
|
||||
|
|
|
@ -9493,12 +9493,13 @@ static bool object_in_any_scene(Main *mainvar, Object *ob)
|
|||
{
|
||||
Scene *sce;
|
||||
|
||||
for (sce= mainvar->scene.first; sce; sce= sce->id.next) {
|
||||
if (BKE_scene_base_find(sce, ob))
|
||||
return 1;
|
||||
for (sce = mainvar->scene.first; sce; sce = sce->id.next) {
|
||||
if (BKE_scene_base_find(sce, ob)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void give_base_to_objects(Main *mainvar, Scene *sce, Library *lib, const short idcode, const bool is_link, const short active_lay)
|
||||
|
@ -9598,7 +9599,7 @@ static void give_base_to_groups(Main *mainvar, Scene *scene)
|
|||
|
||||
/* returns true if the item was found
|
||||
* but it may already have already been appended/linked */
|
||||
static ID *append_named_part(Main *mainl, FileData *fd, const char *idname, const short idcode)
|
||||
static ID *link_named_part(Main *mainl, FileData *fd, const char *idname, const short idcode)
|
||||
{
|
||||
BHead *bhead = find_bhead_from_code_name(fd, idcode, idname);
|
||||
ID *id;
|
||||
|
@ -9637,7 +9638,7 @@ static ID *append_named_part(Main *mainl, FileData *fd, const char *idname, cons
|
|||
}
|
||||
|
||||
/* simple reader for copy/paste buffers */
|
||||
void BLO_library_append_all(Main *mainl, BlendHandle *bh)
|
||||
void BLO_library_link_all(Main *mainl, BlendHandle *bh)
|
||||
{
|
||||
FileData *fd = (FileData *)(bh);
|
||||
BHead *bhead;
|
||||
|
@ -9658,9 +9659,9 @@ void BLO_library_append_all(Main *mainl, BlendHandle *bh)
|
|||
}
|
||||
|
||||
|
||||
static ID *append_named_part_ex(const bContext *C, Main *mainl, FileData *fd, const char *idname, const int idcode, const int flag)
|
||||
static ID *link_named_part_ex(const bContext *C, Main *mainl, FileData *fd, const char *idname, const int idcode, const int flag)
|
||||
{
|
||||
ID *id= append_named_part(mainl, fd, idname, idcode);
|
||||
ID *id = link_named_part(mainl, fd, idname, idcode);
|
||||
|
||||
if (id && (GS(id->name) == ID_OB)) { /* loose object: give a base */
|
||||
Scene *scene = CTX_data_scene(C); /* can be NULL */
|
||||
|
@ -9700,19 +9701,19 @@ static ID *append_named_part_ex(const bContext *C, Main *mainl, FileData *fd, co
|
|||
return id;
|
||||
}
|
||||
|
||||
ID *BLO_library_append_named_part(Main *mainl, BlendHandle **bh, const char *idname, const int idcode)
|
||||
ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const char *idname, const int idcode)
|
||||
{
|
||||
FileData *fd = (FileData*)(*bh);
|
||||
return append_named_part(mainl, fd, idname, idcode);
|
||||
return link_named_part(mainl, fd, idname, idcode);
|
||||
}
|
||||
|
||||
ID *BLO_library_append_named_part_ex(const bContext *C, Main *mainl, BlendHandle **bh, const char *idname, const int idcode, const short flag)
|
||||
ID *BLO_library_link_named_part_ex(const bContext *C, Main *mainl, BlendHandle **bh, const char *idname, const int idcode, const short flag)
|
||||
{
|
||||
FileData *fd = (FileData*)(*bh);
|
||||
return append_named_part_ex(C, mainl, fd, idname, idcode, flag);
|
||||
return link_named_part_ex(C, mainl, fd, idname, idcode, flag);
|
||||
}
|
||||
|
||||
static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **r_id)
|
||||
static void link_id_part(FileData *fd, Main *mainvar, ID *id, ID **r_id)
|
||||
{
|
||||
BHead *bhead = find_bhead_from_idname(fd, id->name);
|
||||
|
||||
|
@ -9726,13 +9727,13 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **r_id)
|
|||
|
||||
/* common routine to append/link something from a library */
|
||||
|
||||
static Main *library_append_begin(Main *mainvar, FileData **fd, const char *filepath)
|
||||
static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepath)
|
||||
{
|
||||
Main *mainl;
|
||||
|
||||
(*fd)->mainlist = MEM_callocN(sizeof(ListBase), "FileData.mainlist");
|
||||
|
||||
/* clear for group instancing tag */
|
||||
/* clear for group instantiating tag */
|
||||
BKE_main_id_tag_listbase(&(mainvar->group), false);
|
||||
|
||||
/* make mains */
|
||||
|
@ -9751,15 +9752,15 @@ static Main *library_append_begin(Main *mainvar, FileData **fd, const char *file
|
|||
return mainl;
|
||||
}
|
||||
|
||||
Main *BLO_library_append_begin(Main *mainvar, BlendHandle **bh, const char *filepath)
|
||||
Main *BLO_library_link_begin(Main *mainvar, BlendHandle **bh, const char *filepath)
|
||||
{
|
||||
FileData *fd = (FileData*)(*bh);
|
||||
return library_append_begin(mainvar, &fd, filepath);
|
||||
return library_link_begin(mainvar, &fd, filepath);
|
||||
}
|
||||
|
||||
|
||||
/* Context == NULL signifies not to do any scene manipulation */
|
||||
static void library_append_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag)
|
||||
static void library_link_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag)
|
||||
{
|
||||
Main *mainvar;
|
||||
Library *curlib;
|
||||
|
@ -9815,7 +9816,7 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
|
|||
}
|
||||
}
|
||||
|
||||
/* clear group instancing tag */
|
||||
/* clear group instantiating tag */
|
||||
BKE_main_id_tag_listbase(&(mainvar->group), false);
|
||||
|
||||
/* has been removed... erm, why? s..ton) */
|
||||
|
@ -9829,10 +9830,10 @@ static void library_append_end(const bContext *C, Main *mainl, FileData **fd, in
|
|||
}
|
||||
}
|
||||
|
||||
void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle **bh, int idcode, short flag)
|
||||
void BLO_library_link_end(const bContext *C, struct Main *mainl, BlendHandle **bh, int idcode, short flag)
|
||||
{
|
||||
FileData *fd = (FileData*)(*bh);
|
||||
library_append_end(C, mainl, &fd, idcode, flag);
|
||||
library_link_end(C, mainl, &fd, idcode, flag);
|
||||
*bh = (BlendHandle*)fd;
|
||||
}
|
||||
|
||||
|
@ -9979,7 +9980,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
|
|||
ID *realid = NULL;
|
||||
BLI_remlink(lbarray[a], id);
|
||||
|
||||
append_id_part(fd, mainptr, id, &realid);
|
||||
link_id_part(fd, mainptr, id, &realid);
|
||||
if (!realid) {
|
||||
blo_reportf_wrap(
|
||||
fd->reports, RPT_WARNING,
|
||||
|
|
|
@ -335,7 +335,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
|||
BKE_main_id_flag_all(bmain, LIB_PRE_EXISTING, true);
|
||||
|
||||
/* here appending/linking starts */
|
||||
mainl = BLO_library_append_begin(bmain, &(self->blo_handle), self->relpath);
|
||||
mainl = BLO_library_link_begin(bmain, &(self->blo_handle), self->relpath);
|
||||
|
||||
{
|
||||
int idcode_step = 0, idcode;
|
||||
|
@ -358,7 +358,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
|||
// printf(" %s\n", item_str);
|
||||
|
||||
if (item_str) {
|
||||
ID *id = BLO_library_append_named_part(mainl, &(self->blo_handle), item_str, idcode);
|
||||
ID *id = BLO_library_link_named_part(mainl, &(self->blo_handle), item_str, idcode);
|
||||
if (id) {
|
||||
#ifdef USE_RNA_DATABLOCKS
|
||||
/* swap name for pointer to the id */
|
||||
|
@ -405,7 +405,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
|
|||
}
|
||||
else {
|
||||
Library *lib = mainl->curlib; /* newly added lib, assign before append end */
|
||||
BLO_library_append_end(NULL, mainl, &(self->blo_handle), 0, self->flag);
|
||||
BLO_library_link_end(NULL, mainl, &(self->blo_handle), 0, self->flag);
|
||||
BLO_blendhandle_close(self->blo_handle);
|
||||
self->blo_handle = NULL;
|
||||
|
||||
|
|
|
@ -2644,7 +2644,7 @@ static void wm_link_append_do_libgroup(
|
|||
}
|
||||
|
||||
/* here appending/linking starts */
|
||||
mainl = BLO_library_append_begin(bmain, &bh, libname);
|
||||
mainl = BLO_library_link_begin(bmain, &bh, libname);
|
||||
lib = mainl->curlib;
|
||||
BLI_assert(lib);
|
||||
|
||||
|
@ -2656,7 +2656,7 @@ static void wm_link_append_do_libgroup(
|
|||
}
|
||||
|
||||
if (name) {
|
||||
BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
|
||||
BLO_library_link_named_part_ex(C, mainl, &bh, name, idcode, flag);
|
||||
}
|
||||
else {
|
||||
if (is_first_run) {
|
||||
|
@ -2680,7 +2680,7 @@ static void wm_link_append_do_libgroup(
|
|||
curr_idcode = BKE_idcode_from_name(group);
|
||||
|
||||
if ((idcode == curr_idcode) && (BLI_path_cmp(curr_libname, libname) == 0)) {
|
||||
BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
|
||||
BLO_library_link_named_part_ex(C, mainl, &bh, name, idcode, flag);
|
||||
}
|
||||
else if (is_first_run) {
|
||||
BLI_join_dirfile(path, sizeof(path), curr_libname, group);
|
||||
|
@ -2692,7 +2692,7 @@ static void wm_link_append_do_libgroup(
|
|||
}
|
||||
RNA_END;
|
||||
}
|
||||
BLO_library_append_end(C, mainl, &bh, idcode, flag);
|
||||
BLO_library_link_end(C, mainl, &bh, idcode, flag);
|
||||
|
||||
BLO_blendhandle_close(bh);
|
||||
|
||||
|
|
|
@ -861,7 +861,7 @@ static void load_datablocks(Main *main_tmp, BlendHandle *bpy_openlib, const char
|
|||
int i = 0;
|
||||
LinkNode *n = names;
|
||||
while (n) {
|
||||
BLO_library_append_named_part(main_tmp, &bpy_openlib, (char *)n->link, idcode);
|
||||
BLO_library_link_named_part(main_tmp, &bpy_openlib, (char *)n->link, idcode);
|
||||
n = (LinkNode *)n->next;
|
||||
i++;
|
||||
}
|
||||
|
@ -905,7 +905,7 @@ KX_LibLoadStatus *KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openl
|
|||
|
||||
short flag = 0; /* don't need any special options */
|
||||
/* created only for linking, then freed */
|
||||
Main *main_tmp = BLO_library_append_begin(main_newlib, &bpy_openlib, (char *)path);
|
||||
Main *main_tmp = BLO_library_link_begin(main_newlib, &bpy_openlib, (char *)path);
|
||||
|
||||
load_datablocks(main_tmp, bpy_openlib, path, idcode);
|
||||
|
||||
|
@ -918,7 +918,7 @@ KX_LibLoadStatus *KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openl
|
|||
load_datablocks(main_tmp, bpy_openlib, path, ID_AC);
|
||||
}
|
||||
|
||||
BLO_library_append_end(NULL, main_tmp, &bpy_openlib, idcode, flag);
|
||||
BLO_library_link_end(NULL, main_tmp, &bpy_openlib, idcode, flag);
|
||||
|
||||
BLO_blendhandle_close(bpy_openlib);
|
||||
|
||||
|
|
Loading…
Reference in New Issue