Fix #135295: Always Restore Previous Editor with set_or_cycle

ED_area_newspace correctly changes an area's space when the type and
subtype are set beforehand. But SCREEN_OT_space_type_set_or_cycle, when
changing to a new editor rather than cycling, needs newspace to ignore
the set subtype and use the last-used saved in the space. This
situation cannot be tested for in newspace. Instead have the operator
pass -1 as subtype to signal this intended behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/135367
This commit is contained in:
Harley Acheson
2025-03-02 21:38:02 +01:00
committed by Harley Acheson
parent 5ddff2562b
commit 1a72a0f22c
2 changed files with 12 additions and 6 deletions

View File

@@ -2601,9 +2601,6 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
wmWindow *win = CTX_wm_window(C);
SpaceType *st = BKE_spacetype_from_id(type);
/* Are we reusing a space already stored in this area? */
bool is_restored_space = false;
if (area->spacetype != type) {
SpaceLink *slold = static_cast<SpaceLink *>(area->spacedata.first);
/* store area->type->exit callback */
@@ -2667,7 +2664,6 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
if (sl) {
/* swap regions */
is_restored_space = true;
slold->regionbase = area->regionbase;
area->regionbase = sl->regionbase;
BLI_listbase_clear(&sl->regionbase);
@@ -2713,10 +2709,18 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
ED_area_tag_refresh(area);
}
/* Set area space subtype if applicable and newly created. */
if (!is_restored_space && st && st->space_subtype_item_extend != nullptr) {
/* Set area space subtype if applicable. */
if (st && st->space_subtype_item_extend != nullptr) {
if (area->butspacetype_subtype == -1) {
/* Indication (probably from space_type_set_or_cycle) to ignore the
* area's current subtype and use last-used, as saved in the space. */
area->butspacetype_subtype = st->space_subtype_get(area);
}
st->space_subtype_set(area, area->butspacetype_subtype);
}
else {
area->butspacetype_subtype = 0;
}
if (BLI_listbase_is_single(&CTX_wm_screen(C)->areabase)) {
/* If there is only one area update the window title. */

View File

@@ -6393,6 +6393,8 @@ static int space_type_set_or_cycle_exec(bContext *C, wmOperator *op)
if (area->spacetype != space_type) {
/* Set the type. */
RNA_property_enum_set(&ptr, prop_type, space_type);
/* Specify that we want last-used if there are subtypes. */
area->butspacetype_subtype = -1;
RNA_property_update(C, &ptr, prop_type);
}
else {