From fa4026f2bf95b7442a3ced8fd0ee3fe0409d8faf Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 18 Feb 2025 14:09:42 +0100 Subject: [PATCH] Revert "Fix #130372: Implements memory of the previous state of eSpace_Types." This reverts commit afec64739a23. The commit introduces a regression where opening the Asset Browser opens the File Browser instead, same for other editor sub-types, see blender/blender#134630. blender/blender!134642 proposes a different solution and reverts this, which I prefer too. Better to the revert separately from trying a different fix for the initial bug, makes reviewing easier too. --- source/blender/blenkernel/BKE_screen.hh | 1 - source/blender/editors/screen/area.cc | 11 +++-------- .../editors/space_action/space_action.cc | 18 +++++++++--------- .../blender/editors/space_file/space_file.cc | 8 -------- .../blender/editors/space_graph/space_graph.cc | 8 -------- .../blender/editors/space_image/space_image.cc | 18 +++++++++--------- .../blender/editors/space_node/space_node.cc | 18 ------------------ source/blender/makesdna/DNA_screen_types.h | 2 +- source/blender/makesdna/DNA_space_types.h | 6 ++---- 9 files changed, 24 insertions(+), 66 deletions(-) diff --git a/source/blender/blenkernel/BKE_screen.hh b/source/blender/blenkernel/BKE_screen.hh index 8af22490bd2..0bc7c18c2e1 100644 --- a/source/blender/blenkernel/BKE_screen.hh +++ b/source/blender/blenkernel/BKE_screen.hh @@ -130,7 +130,6 @@ struct SpaceType { int (*space_subtype_get)(ScrArea *area); void (*space_subtype_set)(ScrArea *area, int value); void (*space_subtype_item_extend)(bContext *C, EnumPropertyItem **item, int *totitem); - int (*space_subtype_prev_get)(ScrArea *area); /* Return a custom name, based on subtype or other reason. */ blender::StringRefNull (*space_name_get)(const ScrArea *area); diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index aab3ea4faf8..f370fe9b74b 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -2601,9 +2601,7 @@ 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); - const bool change_spacetype = area->spacetype != type; - - if (change_spacetype) { + if (area->spacetype != type) { SpaceLink *slold = static_cast(area->spacedata.first); /* store area->type->exit callback */ void (*area_exit)(wmWindowManager *, ScrArea *) = area->type ? area->type->exit : nullptr; @@ -2712,13 +2710,10 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi } /* Set area space subtype if applicable. */ - if (st && st->space_subtype_item_extend != nullptr) { - BLI_assert(st->space_subtype_prev_get != nullptr); + if (st->space_subtype_item_extend != nullptr) { st->space_subtype_set(area, area->butspacetype_subtype); - if (change_spacetype) { - st->space_subtype_set(area, st->space_subtype_prev_get(area)); - } } + area->butspacetype_subtype = 0; if (BLI_listbase_is_single(&CTX_wm_screen(C)->areabase)) { /* If there is only one area update the window title. */ diff --git a/source/blender/editors/space_action/space_action.cc b/source/blender/editors/space_action/space_action.cc index f3fa6551d0a..8b5a2fdaaeb 100644 --- a/source/blender/editors/space_action/space_action.cc +++ b/source/blender/editors/space_action/space_action.cc @@ -874,8 +874,15 @@ static int action_space_subtype_get(ScrArea *area) static void action_space_subtype_set(ScrArea *area, int value) { SpaceAction *sact = static_cast(area->spacedata.first); - sact->mode_prev = sact->mode; - sact->mode = value; + if (value == SACTCONT_TIMELINE) { + if (sact->mode != SACTCONT_TIMELINE) { + sact->mode_prev = sact->mode; + } + sact->mode = value; + } + else { + sact->mode = sact->mode_prev; + } } static void action_space_subtype_item_extend(bContext * /*C*/, @@ -885,12 +892,6 @@ static void action_space_subtype_item_extend(bContext * /*C*/, RNA_enum_items_add(item, totitem, rna_enum_space_action_mode_items); } -static int action_space_subtype_prev_get(ScrArea *area) -{ - SpaceAction *sact = static_cast(area->spacedata.first); - return sact->mode_prev; -} - static blender::StringRefNull action_space_name_get(const ScrArea *area) { SpaceAction *sact = static_cast(area->spacedata.first); @@ -939,7 +940,6 @@ void ED_spacetype_action() st->space_subtype_item_extend = action_space_subtype_item_extend; st->space_subtype_get = action_space_subtype_get; st->space_subtype_set = action_space_subtype_set; - st->space_subtype_prev_get = action_space_subtype_prev_get; st->space_name_get = action_space_name_get; st->space_icon_get = action_space_icon_get; st->blend_read_data = action_space_blend_read_data; diff --git a/source/blender/editors/space_file/space_file.cc b/source/blender/editors/space_file/space_file.cc index 9194edaf934..248e4f9006c 100644 --- a/source/blender/editors/space_file/space_file.cc +++ b/source/blender/editors/space_file/space_file.cc @@ -824,7 +824,6 @@ static void file_space_subtype_set(ScrArea *area, int value) LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { region->v2d.flag &= ~V2D_IS_INIT; } - sfile->browse_mode_prev = sfile->browse_mode; sfile->browse_mode = value; } @@ -833,12 +832,6 @@ static void file_space_subtype_item_extend(bContext * /*C*/, EnumPropertyItem ** RNA_enum_items_add(item, totitem, rna_enum_space_file_browse_mode_items); } -static int file_space_subtype_prev_get(ScrArea *area) -{ - SpaceFile *sfile = static_cast(area->spacedata.first); - return sfile->browse_mode_prev; -} - static blender::StringRefNull file_space_name_get(const ScrArea *area) { SpaceFile *sfile = static_cast(area->spacedata.first); @@ -950,7 +943,6 @@ void ED_spacetype_file() st->space_subtype_item_extend = file_space_subtype_item_extend; st->space_subtype_get = file_space_subtype_get; st->space_subtype_set = file_space_subtype_set; - st->space_subtype_prev_get = file_space_subtype_prev_get; st->space_name_get = file_space_name_get; st->space_icon_get = file_space_icon_get; st->context = file_context; diff --git a/source/blender/editors/space_graph/space_graph.cc b/source/blender/editors/space_graph/space_graph.cc index b20cf4d1677..528431722dc 100644 --- a/source/blender/editors/space_graph/space_graph.cc +++ b/source/blender/editors/space_graph/space_graph.cc @@ -865,7 +865,6 @@ static int graph_space_subtype_get(ScrArea *area) static void graph_space_subtype_set(ScrArea *area, int value) { SpaceGraph *sgraph = static_cast(area->spacedata.first); - sgraph->mode_prev = sgraph->mode; sgraph->mode = value; } @@ -876,12 +875,6 @@ static void graph_space_subtype_item_extend(bContext * /*C*/, RNA_enum_items_add(item, totitem, rna_enum_space_graph_mode_items); } -static int graph_space_subtype_prev_get(ScrArea *area) -{ - SpaceGraph *sgraph = static_cast(area->spacedata.first); - return sgraph->mode_prev; -} - static blender::StringRefNull graph_space_name_get(const ScrArea *area) { SpaceGraph *sgraph = static_cast(area->spacedata.first); @@ -944,7 +937,6 @@ void ED_spacetype_ipo() st->space_subtype_item_extend = graph_space_subtype_item_extend; st->space_subtype_get = graph_space_subtype_get; st->space_subtype_set = graph_space_subtype_set; - st->space_subtype_prev_get = graph_space_subtype_prev_get; st->space_name_get = graph_space_name_get; st->space_icon_get = graph_space_icon_get; st->blend_read_data = graph_space_blend_read_data; diff --git a/source/blender/editors/space_image/space_image.cc b/source/blender/editors/space_image/space_image.cc index da48e157b2c..235b4956ff6 100644 --- a/source/blender/editors/space_image/space_image.cc +++ b/source/blender/editors/space_image/space_image.cc @@ -1062,8 +1062,15 @@ static int image_space_subtype_get(ScrArea *area) static void image_space_subtype_set(ScrArea *area, int value) { SpaceImage *sima = static_cast(area->spacedata.first); - sima->mode_prev = sima->mode; - sima->mode = value; + if (value == SI_MODE_UV) { + if (sima->mode != SI_MODE_UV) { + sima->mode_prev = sima->mode; + } + sima->mode = value; + } + else { + sima->mode = sima->mode_prev; + } } static void image_space_subtype_item_extend(bContext * /*C*/, @@ -1073,12 +1080,6 @@ static void image_space_subtype_item_extend(bContext * /*C*/, RNA_enum_items_add(item, totitem, rna_enum_space_image_mode_items); } -static int image_space_subtype_prev_get(ScrArea *area) -{ - SpaceImage *sima = static_cast(area->spacedata.first); - return sima->mode_prev; -} - static blender::StringRefNull image_space_name_get(const ScrArea *area) { SpaceImage *sima = static_cast(area->spacedata.first); @@ -1156,7 +1157,6 @@ void ED_spacetype_image() st->space_subtype_item_extend = image_space_subtype_item_extend; st->space_subtype_get = image_space_subtype_get; st->space_subtype_set = image_space_subtype_set; - st->space_subtype_prev_get = image_space_subtype_prev_get; st->space_name_get = image_space_name_get; st->space_icon_get = image_space_icon_get; st->blend_read_data = image_space_blend_read_data; diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index cc12976ff54..b22939101cf 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -1317,17 +1317,6 @@ static int node_space_subtype_get(ScrArea *area) static void node_space_subtype_set(ScrArea *area, int value) { SpaceNode *snode = static_cast(area->spacedata.first); - int value_prev = node_space_subtype_get(area); - - /* Save the subtype. */ - blender::bke::bNodeTreeType *typeinfo = rna_node_tree_type_from_enum(value_prev); - if (typeinfo) { - STRNCPY(snode->tree_idname_prev, typeinfo->idname.c_str()); - } - else { - snode->tree_idname_prev[0] = '\0'; - } - ED_node_set_tree_type(snode, rna_node_tree_type_from_enum(value)); } @@ -1341,12 +1330,6 @@ static void node_space_subtype_item_extend(bContext *C, EnumPropertyItem **item, } } -static int node_space_subtype_prev_get(ScrArea *area) -{ - SpaceNode *snode = static_cast(area->spacedata.first); - return rna_node_tree_idname_to_enum(snode->tree_idname_prev); -} - static blender::StringRefNull node_space_name_get(const ScrArea *area) { SpaceNode *snode = static_cast(area->spacedata.first); @@ -1420,7 +1403,6 @@ void ED_spacetype_node() st->space_subtype_item_extend = node_space_subtype_item_extend; st->space_subtype_get = node_space_subtype_get; st->space_subtype_set = node_space_subtype_set; - st->space_subtype_prev_get = node_space_subtype_prev_get; st->space_name_get = node_space_name_get; st->space_icon_get = node_space_icon_get; st->blend_read_data = node_space_blend_read_data; diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index b4fcf074c22..eb0b1bb239b 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -439,7 +439,6 @@ typedef struct ScrArea { */ char butspacetype; short butspacetype_subtype; - short butspacetype_subtype_prev; /** Size. */ short winx, winy; @@ -454,6 +453,7 @@ typedef struct ScrArea { * runtime variable, updated by executing operators. */ short region_active_win; + char _pad[2]; /** Callbacks for this space type. */ struct SpaceType *type; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 3f4308359ed..ea89cb1c0f3 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -484,10 +484,8 @@ typedef struct SpaceGraph { /** Mode for the Graph editor (eGraphEdit_Mode). */ short mode; - short mode_prev; /* Snapping now lives on the Scene. */ short autosnap DNA_DEPRECATED; - char _pad[2]; /** Settings for Graph editor (eGraphEdit_Flag). */ int flag; @@ -497,6 +495,7 @@ typedef struct SpaceGraph { float cursorVal; /** Pivot point for transforms. */ int around; + char _pad[4]; SpaceGraph_Runtime runtime; } SpaceGraph; @@ -915,7 +914,7 @@ typedef struct SpaceFile { /** Is this a File Browser or an Asset Browser? */ char browse_mode; /* eFileBrowse_Mode */ - char browse_mode_prev; + char _pad1[1]; short tags; @@ -1610,7 +1609,6 @@ typedef struct SpaceNode { /* tree type for the current node tree */ char tree_idname[64]; - char tree_idname_prev[64]; /** Same as #bNodeTree::type (deprecated). */ int treetype DNA_DEPRECATED;