diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-16 05:30:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-16 05:50:00 +0300 |
commit | 2209321f7817f349874cd03003c184408a286511 (patch) | |
tree | 73e5e9f71b7687e9b4f7063de1033f6b339afbc0 /source/blender/editors/screen | |
parent | be8a201a164f8a3ab2e61b1d85bbe75ebfbb0b30 (diff) |
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.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 21 |
1 files changed, 16 insertions, 5 deletions
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); |