diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-12-04 15:57:26 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-12-04 16:07:39 +0300 |
commit | 47fa3e7b27623f85acba9161e5210507a67742f1 (patch) | |
tree | fcb4eb7d999c2350fa27dee90056e31b7660c3a4 /source | |
parent | a1df65c9ddd3d876904cd4d26da5c2760a52191c (diff) | |
parent | 0868a2b6109f974edcc11a35c9f1bbd0388a8864 (diff) |
Merge branch 'master' into blender2.8
Conflicts:
source/blender/blenloader/BLO_readfile.h
source/blender/blenloader/intern/readfile.c
source/blender/windowmanager/intern/wm_files_link.c
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 18 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 33 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files_link.c | 20 |
4 files changed, 45 insertions, 28 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 00d00e98c84..0da15fe5bbc 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -119,14 +119,24 @@ void BLO_blendhandle_close(BlendHandle *bh); bool BLO_has_bfile_extension(const char *str); bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name); +/* Options controlling behavior of append/link code. + * Note: merged with 'user-level' options from operators etc. in 16 lower bits + * (see eFileSel_Params_Flag in DNA_space_types.h). */ +typedef enum BLO_LibLinkFlags { + /* Generate a placeholder (empty ID) if not found in current lib file. */ + BLO_LIBLINK_USE_PLACEHOLDERS = 1 << 16, + /* Force loaded ID to be tagged as LIB_TAG_INDIRECT (used in reload context only). */ + BLO_LIBLINK_FORCE_INDIRECT = 1 << 17, +} BLO_LinkFlags; + struct Main *BLO_library_link_begin(struct Main *mainvar, BlendHandle **bh, const char *filepath); struct ID *BLO_library_link_named_part(struct Main *mainl, BlendHandle **bh, const short idcode, const char *name); struct ID *BLO_library_link_named_part_ex( struct Main *mainl, BlendHandle **bh, - const short idcode, const char *name, const short flag, - struct Scene *scene, struct ViewLayer *view_layer, - const bool use_placeholders, const bool force_indirect); -void BLO_library_link_end(struct Main *mainl, BlendHandle **bh, short flag, struct Scene *scene, struct ViewLayer *view_layer); + const short idcode, const char *name, const int flag, + struct Scene *scene, struct ViewLayer *view_layer); +void BLO_library_link_end( + struct Main *mainl, BlendHandle **bh, int flag, struct Scene *scene, struct ViewLayer *view_layer); void BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9e09d2e0bd1..6df5a505788 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -254,7 +254,8 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb); static BHead *find_bhead_from_code_name(FileData *fd, const short idcode, const char *name); static BHead *find_bhead_from_idname(FileData *fd, const char *idname); static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc); -static SceneCollection *get_scene_collection_active_or_create(struct Scene *scene, struct ViewLayer *view_layer, const short flag); +static SceneCollection *get_scene_collection_active_or_create( + struct Scene *scene, struct ViewLayer *view_layer, const int flag); /* this function ensures that reports are printed, * in the case of libraray linking errors this is important! @@ -10373,12 +10374,14 @@ static ID *create_placeholder(Main *mainvar, const short idcode, const char *idn /* returns true if the item was found * but it may already have already been appended/linked */ static ID *link_named_part( - Main *mainl, FileData *fd, const short idcode, const char *name, - const bool use_placeholders, const bool force_indirect) + Main *mainl, FileData *fd, const short idcode, const char *name, const int flag) { BHead *bhead = find_bhead_from_code_name(fd, idcode, name); ID *id; + const bool use_placeholders = (flag & BLO_LIBLINK_USE_PLACEHOLDERS) != 0; + const bool force_indirect = (flag & BLO_LIBLINK_FORCE_INDIRECT) != 0; + BLI_assert(BKE_idcode_is_linkable(idcode) && BKE_idcode_is_valid(idcode)); if (bhead) { @@ -10418,7 +10421,8 @@ static ID *link_named_part( return id; } -static SceneCollection *get_scene_collection_active_or_create(struct Scene *scene, struct ViewLayer *view_layer, const short flag) +static SceneCollection *get_scene_collection_active_or_create( + struct Scene *scene, struct ViewLayer *view_layer, const int flag) { LayerCollection *lc = NULL; @@ -10433,7 +10437,7 @@ static SceneCollection *get_scene_collection_active_or_create(struct Scene *scen return lc->scene_collection; } -static void link_object_postprocess(ID *id, Scene *scene, ViewLayer *view_layer, const short flag) +static void link_object_postprocess(ID *id, Scene *scene, ViewLayer *view_layer, const int flag) { if (scene) { /* link to scene */ @@ -10495,10 +10499,10 @@ void BLO_library_link_copypaste(Main *mainl, BlendHandle *bh) } static ID *link_named_part_ex( - Main *mainl, FileData *fd, const short idcode, const char *name, const short flag, - Scene *scene, ViewLayer *view_layer, const bool use_placeholders, const bool force_indirect) + Main *mainl, FileData *fd, const short idcode, const char *name, const int flag, + Scene *scene, ViewLayer *view_layer) { - ID *id = link_named_part(mainl, fd, idcode, name, use_placeholders, force_indirect); + ID *id = link_named_part(mainl, fd, idcode, name, flag); if (id && (GS(id->name) == ID_OB)) { /* loose object: give a base */ link_object_postprocess(id, scene, view_layer, flag); @@ -10524,7 +10528,7 @@ static ID *link_named_part_ex( ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const short idcode, const char *name) { FileData *fd = (FileData*)(*bh); - return link_named_part(mainl, fd, idcode, name, false, false); + return link_named_part(mainl, fd, idcode, name, 0); } /** @@ -10538,18 +10542,15 @@ ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const short idcod * \param flag Options for linking, used for instantiating. * \param scene The scene in which to instantiate objects/groups (if NULL, no instantiation is done). * \param v3d The active View3D (only to define active layers for instantiated objects & groups, can be NULL). - * \param use_placeholders If true, generate a placeholder (empty ID) if not found in current lib file. - * \param force_indirect If true, force loaded ID to be tagged as LIB_TAG_INDIRECT (used in reload context only). * \return the linked ID when found. */ ID *BLO_library_link_named_part_ex( Main *mainl, BlendHandle **bh, - const short idcode, const char *name, const short flag, - Scene *scene, ViewLayer *view_layer, - const bool use_placeholders, const bool force_indirect) + const short idcode, const char *name, const int flag, + Scene *scene, ViewLayer *view_layer) { FileData *fd = (FileData*)(*bh); - return link_named_part_ex(mainl, fd, idcode, name, flag, scene, view_layer, use_placeholders, force_indirect); + return link_named_part_ex(mainl, fd, idcode, name, flag, scene, view_layer); } static void link_id_part(ReportList *reports, FileData *fd, Main *mainvar, ID *id, ID **r_id) @@ -10749,7 +10750,7 @@ static void library_link_end(Main *mainl, FileData **fd, const short flag, Scene * \param scene The scene in which to instantiate objects/groups (if NULL, no instantiation is done). * \param view_layer The scene layer in which to instantiate objects/groups (if NULL, no instantiation is done). */ -void BLO_library_link_end(Main *mainl, BlendHandle **bh, short flag, Scene *scene, ViewLayer *view_layer) +void BLO_library_link_end(Main *mainl, BlendHandle **bh, int flag, Scene *scene, ViewLayer *view_layer) { FileData *fd = (FileData*)(*bh); library_link_end(mainl, &fd, flag, scene, view_layer); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 0e0d40a38f1..39ac3f72b94 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -719,6 +719,8 @@ typedef enum eFileSel_Action { } eFileSel_Action; /* sfile->params->flag and simasel->flag */ +/* Note: short flag, also used as 16 lower bits of flags in link/append code + * (WM and BLO code area, see BLO_LibLinkFlags in BLO_readfile.h). */ typedef enum eFileSel_Params_Flag { FILE_SHOWSHORT = (1 << 0), FILE_RELPATH = (1 << 1), /* was FILE_STRINGCODE */ diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index 2086ade99d2..cd6a38cb9a8 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -159,7 +159,7 @@ typedef struct WMLinkAppendData { LinkNodePair items; int num_libraries; int num_items; - short flag; + int flag; /* Combines eFileSel_Params_Flag from DNA_space_types.h and BLO_LibLinkFlags from BLO_readfile.h */ /* Internal 'private' data */ MemArena *memarena; @@ -214,8 +214,7 @@ static WMLinkAppendDataItem *wm_link_append_data_item_add( } static void wm_link_do( - WMLinkAppendData *lapp_data, ReportList *reports, Main *bmain, Scene *scene, ViewLayer *view_layer, - const bool use_placeholders, const bool force_indirect) + WMLinkAppendData *lapp_data, ReportList *reports, Main *bmain, Scene *scene, ViewLayer *view_layer) { Main *mainl; BlendHandle *bh; @@ -262,8 +261,7 @@ static void wm_link_do( continue; } - new_id = BLO_library_link_named_part_ex( - mainl, &bh, item->idcode, item->name, flag, scene, view_layer, use_placeholders, force_indirect); + new_id = BLO_library_link_named_part_ex(mainl, &bh, item->idcode, item->name, flag, scene, view_layer); if (new_id) { /* If the link is successful, clear item's libs 'todo' flags. @@ -372,6 +370,8 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) scene = NULL; } + /* We need to add nothing from BLO_LibLinkFlags to flag here. */ + /* from here down, no error returns */ if (view_layer && RNA_boolean_get(op->ptr, "autoselect")) { @@ -453,7 +453,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* XXX We'd need re-entrant locking on Main for this to work... */ /* BKE_main_lock(bmain); */ - wm_link_do(lapp_data, op->reports, bmain, scene, view_layer, false, false); + wm_link_do(lapp_data, op->reports, bmain, scene, view_layer); /* BKE_main_unlock(bmain); */ @@ -653,7 +653,7 @@ static void lib_relocate_do( BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, true); /* We do not want any instanciation here! */ - wm_link_do(lapp_data, reports, bmain, NULL, NULL, do_reload, do_reload); + wm_link_do(lapp_data, reports, bmain, NULL, NULL); BKE_main_lock(bmain); @@ -814,7 +814,7 @@ void WM_lib_reload(Library *lib, bContext *C, ReportList *reports) return; } - WMLinkAppendData *lapp_data = wm_link_append_data_new(0); + WMLinkAppendData *lapp_data = wm_link_append_data_new(BLO_LIBLINK_USE_PLACEHOLDERS | BLO_LIBLINK_FORCE_INDIRECT); wm_link_append_data_library_add(lapp_data, lib->filepath); @@ -924,6 +924,10 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload) } } + if (do_reload) { + lapp_data->flag |= BLO_LIBLINK_USE_PLACEHOLDERS | BLO_LIBLINK_FORCE_INDIRECT; + } + lib_relocate_do(bmain, lib, lapp_data, op->reports, do_reload); wm_link_append_data_free(lapp_data); |