From 2209321f7817f349874cd03003c184408a286511 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Jun 2021 12:30:48 +1000 Subject: Screen: simplify internal logic for new full-screen areas Creating a new full screen area had it's area initialized as empty, updating the screen then set the area to a 3D view (as a fallback), before the actual area type was set. This made setting the intended space-type run the 3D views exit callback on a 3D view without a View3D struct allocated, which the exit callback needed to account for. Resolve by calling ED_screen_change after the area type has been set. --- source/blender/editors/screen/screen_edit.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/screen') diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 6cb184a3394..bcfe30a829e 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1275,11 +1275,14 @@ void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene) ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *area, int type) { + bScreen *newscreen = NULL; ScrArea *newsa = NULL; SpaceLink *newsl; if (!area || area->full == NULL) { - newsa = ED_screen_state_maximized_create(C); + newscreen = ED_screen_state_maximized_create(C); + newsa = newscreen->areabase.first; + BLI_assert(newsa->spacetype == SPACE_EMPTY); } if (!newsa) { @@ -1296,6 +1299,10 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *area, int type) ED_area_newspace(C, newsa, type, (newsl && newsl->link_flag & SPACE_FLAG_TYPE_TEMPORARY)); + if (newscreen) { + ED_screen_change(C, newscreen); + } + return newsa; } @@ -1361,6 +1368,10 @@ void ED_screen_full_restore(bContext *C, ScrArea *area) * \param toggle_area: If this is set, its space data will be swapped with the one of the new empty * area, when toggling back it can be swapped back again. * \return The newly created screen with the non-normal area. + * + * \note The caller must run #ED_screen_change this is not done in this function + * as it would attempt to initialize areas that don't yet have a space-type assigned + * (converting them to 3D view without creating the space-data). */ static bScreen *screen_state_to_nonnormal(bContext *C, wmWindow *win, @@ -1429,7 +1440,6 @@ static bScreen *screen_state_to_nonnormal(bContext *C, } newa->full = oldscreen; - ED_screen_change(C, screen); ED_area_tag_refresh(newa); return screen; @@ -1442,10 +1452,9 @@ static bScreen *screen_state_to_nonnormal(bContext *C, * Use this to just create a new maximized screen/area, rather than maximizing an existing one. * Otherwise, maximize with #ED_screen_state_toggle(). */ -ScrArea *ED_screen_state_maximized_create(bContext *C) +bScreen *ED_screen_state_maximized_create(bContext *C) { - bScreen *screen = screen_state_to_nonnormal(C, CTX_wm_window(C), NULL, SCREENMAXIMIZED); - return screen->areabase.first; + return screen_state_to_nonnormal(C, CTX_wm_window(C), NULL, SCREENMAXIMIZED); } /** @@ -1548,6 +1557,8 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const } screen = screen_state_to_nonnormal(C, win, toggle_area, state); + + ED_screen_change(C, screen); } BLI_assert(CTX_wm_screen(C) == screen); -- cgit v1.2.3