diff options
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 59 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 3 |
3 files changed, 62 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 19f260fb3a7..e8c96cb7d1b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6402,6 +6402,7 @@ static void direct_link_area(FileData *fd, ScrArea *area) /* if we do not have the spacetype registered we cannot * free it, so don't allocate any new memory for such spacetypes. */ if (!BKE_spacetype_exists(area->spacetype)) { + area->butspacetype = area->spacetype; /* Hint for versioning code to replace deprecated space types. */ area->spacetype = SPACE_EMPTY; } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index ff4a0351a7b..661b7b53260 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -112,6 +112,31 @@ static void do_version_workspaces_create_from_screens(Main *bmain) } } +static void do_version_area_change_space_to_space_action(ScrArea *area, const Scene *scene) +{ + SpaceType *stype = BKE_spacetype_from_id(SPACE_ACTION); + SpaceAction *saction = (SpaceAction *)stype->new(area, scene); + ARegion *region_channels; + + /* Properly free current regions */ + for (ARegion *region = area->regionbase.first; region; region = region->next) { + BKE_area_region_free(area->type, region); + } + BLI_freelistN(&area->regionbase); + + area->type = stype; + area->spacetype = stype->spaceid; + + BLI_addhead(&area->spacedata, saction); + area->regionbase = saction->regionbase; + BLI_listbase_clear(&saction->regionbase); + + /* Different defaults for timeline */ + region_channels = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS); + region_channels->flag |= RGN_FLAG_HIDDEN; + saction->mode = SACTCONT_TIMELINE; +} + /** * \brief After lib-link versioning for new workspace design. * @@ -625,6 +650,40 @@ void do_versions_after_linking_280(Main *main) } } } + + /* SpaceTime & SpaceLogic removal/replacing */ + if (!MAIN_VERSION_ATLEAST(main, 280, 9)) { + const wmWindowManager *wm = main->wm.first; + const Scene *scene = main->scene.first; + + /* Action editors need a scene for creation. First, update active + * screens using the active scene of the window they're displayed in. + * Next, update remaining screens using first scene in main listbase. */ + + for (wmWindow *win = wm->windows.first; win; win = win->next) { + const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) { + do_version_area_change_space_to_space_action(area, win->scene); + + /* Don't forget to unset! */ + area->butspacetype = SPACE_EMPTY; + } + } + } + + for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { + for (ScrArea *area = screen->areabase.first; area; area = area->next) { + if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) { + /* Areas that were already handled won't be handled again */ + do_version_area_change_space_to_space_action(area, scene); + + /* Don't forget to unset! */ + area->butspacetype = SPACE_EMPTY; + } + } + } + } } static void do_version_layer_collections_idproperties(ListBase *lb) diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 1d0fbf36912..73a9beb7ab5 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -253,7 +253,8 @@ typedef struct ScrArea { char spacetype; /* eSpace_Type (SPACE_FOO) */ /* Temporarily used while switching area type, otherwise this should be - * SPACE_EMPTY. It's been there for ages, name doesn't fit any more. */ + * SPACE_EMPTY. Also, versioning uses it to nicely replace deprecated + * editors. It's been there for ages, name doesn't fit any more... */ char butspacetype; /* eSpace_Type (SPACE_FOO) */ short winx, winy; /* size */ |