Fix crash reading old userpref.blend

While window manager is supposed to exist after file was fully read
and do-versioned, we can not rely on window manager to exist while
reading file and setting up an environment.
This commit is contained in:
Sergey Sharybin 2018-04-23 11:45:40 +02:00
parent 63c4654135
commit fdf5834b44

@ -654,32 +654,34 @@ void do_versions_after_linking_280(Main *main)
/* SpaceTime & SpaceLogic removal/replacing */ /* SpaceTime & SpaceLogic removal/replacing */
if (!MAIN_VERSION_ATLEAST(main, 280, 9)) { if (!MAIN_VERSION_ATLEAST(main, 280, 9)) {
const wmWindowManager *wm = main->wm.first; const wmWindowManager *wm = main->wm.first;
const Scene *scene = main->scene.first; if (wm != NULL) {
const Scene *scene = main->scene.first;
/* Action editors need a scene for creation. First, update active /* Action editors need a scene for creation. First, update active
* screens using the active scene of the window they're displayed in. * screens using the active scene of the window they're displayed in.
* Next, update remaining screens using first scene in main listbase. */ * Next, update remaining screens using first scene in main listbase. */
for (wmWindow *win = wm->windows.first; win; win = win->next) { for (wmWindow *win = wm->windows.first; win; win = win->next) {
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook); const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
for (ScrArea *area = screen->areabase.first; area; area = area->next) { for (ScrArea *area = screen->areabase.first; area; area = area->next) {
if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) { if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
do_version_area_change_space_to_space_action(area, win->scene); do_version_area_change_space_to_space_action(area, win->scene);
/* Don't forget to unset! */ /* Don't forget to unset! */
area->butspacetype = SPACE_EMPTY; area->butspacetype = SPACE_EMPTY;
}
} }
} }
}
for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) {
for (ScrArea *area = screen->areabase.first; area; area = area->next) { for (ScrArea *area = screen->areabase.first; area; area = area->next) {
if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) { if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
/* Areas that were already handled won't be handled again */ /* Areas that were already handled won't be handled again */
do_version_area_change_space_to_space_action(area, scene); do_version_area_change_space_to_space_action(area, scene);
/* Don't forget to unset! */ /* Don't forget to unset! */
area->butspacetype = SPACE_EMPTY; area->butspacetype = SPACE_EMPTY;
}
} }
} }
} }