From 3042994c91667f9c8a1ecadc11e69c012c33d581 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 23 Sep 2021 10:43:31 +0200 Subject: Link/Append: Refactor flags. Flags controlling link/append code are split between two enums, one in `DNA_space_types.h` and one in `BLO_readfile.h`. This commit: - Moves flags exclusively used in WM and BLO code to `eBLOLibLinkFlags` in `BLO_readfile.h`. Flags in `eFileSel_Params_Flag` from `DNA_space_types.h` are now only the ones effectively used by the file browser editor code too. - Fixes some internal utils in `readfile.c` still taking `short` flag parameter instead of proper `int` one. NOTE: there are a few other flags that could probably be moved to `eBLOLibLinkFlags` (at the very least `FILE_LINK`, probably also `FILE_AUTOSELECT` and `FILE_ACTIVE_COLLECTION`), since those are not effectively used by the file browser, and control linking/appending behavior, not filebrowser behavior. However for now think it's safer to not touch that. --- source/blender/blenloader/BLO_readfile.h | 8 ++++++++ source/blender/blenloader/intern/readfile.c | 12 ++++++------ source/blender/blenloader/intern/versioning_280.c | 4 ++-- source/blender/blenloader/intern/versioning_300.c | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+), 8 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 4b7f29dd7dc..1f0203b45e9 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -209,6 +209,14 @@ typedef enum eBLOLibLinkFlags { * don't need to remember to set this flag. */ BLO_LIBLINK_NEEDS_ID_TAG_DOIT = 1 << 18, + /** Set fake user on appended IDs. */ + BLO_LIBLINK_APPEND_SET_FAKEUSER = 1 << 19, + /** Append (make local) also indirect dependencies of appendeds IDs. */ + BLO_LIBLINK_APPEND_RECURSIVE = 1 << 20, + /** Instantiate object data IDs (i.e. create objects for them if needed). */ + BLO_LIBLINK_OBDATA_INSTANCE = 1 << 21, + /** Instantiate collections as empties, instead of linking them into current view layer. */ + BLO_LIBLINK_COLLECTION_INSTANCE = 1 << 22, } eBLOLibLinkFlags; /** diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3cda1e613f8..cdae043d01c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4496,7 +4496,7 @@ static void add_loose_objects_to_scene(Main *mainvar, ViewLayer *view_layer, const View3D *v3d, Library *lib, - const short flag) + const int flag) { Collection *active_collection = NULL; const bool do_append = (flag & FILE_LINK) == 0; @@ -4556,9 +4556,9 @@ static void add_loose_object_data_to_scene(Main *mainvar, Scene *scene, ViewLayer *view_layer, const View3D *v3d, - const short flag) + const int flag) { - if ((flag & FILE_OBDATA_INSTANCE) == 0) { + if ((flag & BLO_LIBLINK_OBDATA_INSTANCE) == 0) { return; } @@ -4617,7 +4617,7 @@ static void add_collections_to_scene(Main *mainvar, ViewLayer *view_layer, const View3D *v3d, Library *lib, - const short flag) + const int flag) { Collection *active_collection = scene->master_collection; if (flag & FILE_ACTIVE_COLLECTION) { @@ -4627,7 +4627,7 @@ static void add_collections_to_scene(Main *mainvar, /* Give all objects which are tagged a base. */ LISTBASE_FOREACH (Collection *, collection, &mainvar->collections) { - if ((flag & FILE_COLLECTION_INSTANCE) && (collection->id.tag & LIB_TAG_DOIT)) { + if ((flag & BLO_LIBLINK_COLLECTION_INSTANCE) && (collection->id.tag & LIB_TAG_DOIT)) { /* Any indirect collection should not have been tagged. */ BLI_assert((collection->id.tag & LIB_TAG_INDIRECT) == 0); @@ -4830,7 +4830,7 @@ static bool library_link_idcode_needs_tag_check(const short idcode, const int fl if (ELEM(idcode, ID_OB, ID_GR)) { return true; } - if (flag & FILE_OBDATA_INSTANCE) { + if (flag & BLO_LIBLINK_OBDATA_INSTANCE) { if (OB_DATA_SUPPORT_ID(idcode)) { return true; } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 69b67460a5d..292ca726b6f 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3416,8 +3416,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) case SPACE_FILE: { SpaceFile *sfile = (SpaceFile *)sl; if (sfile->params) { - sfile->params->flag &= ~(FILE_APPEND_SET_FAKEUSER | FILE_APPEND_RECURSIVE | - FILE_OBDATA_INSTANCE); + sfile->params->flag &= ~(FILE_PARAMS_FLAG_UNUSED_1 | FILE_PARAMS_FLAG_UNUSED_2 | + FILE_PARAMS_FLAG_UNUSED_3); } break; } diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index 58265bca238..9908e231452 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -1438,5 +1438,24 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + switch (sl->spacetype) { + case SPACE_FILE: { + SpaceFile *sfile = (SpaceFile *)sl; + if (sfile->params) { + sfile->params->flag &= ~(FILE_PARAMS_FLAG_UNUSED_1 | FILE_PARAMS_FLAG_UNUSED_2 | + FILE_PARAMS_FLAG_UNUSED_3 | FILE_PARAMS_FLAG_UNUSED_4); + } + break; + } + default: + break; + } + } + } + } } } -- cgit v1.2.3