Revert "Fix #130372: Implements memory of the previous state of eSpace_Types."
This reverts commit afec64739a.
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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<SpaceLink *>(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. */
|
||||
|
||||
@@ -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<SpaceAction *>(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<SpaceAction *>(area->spacedata.first);
|
||||
return sact->mode_prev;
|
||||
}
|
||||
|
||||
static blender::StringRefNull action_space_name_get(const ScrArea *area)
|
||||
{
|
||||
SpaceAction *sact = static_cast<SpaceAction *>(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;
|
||||
|
||||
@@ -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<SpaceFile *>(area->spacedata.first);
|
||||
return sfile->browse_mode_prev;
|
||||
}
|
||||
|
||||
static blender::StringRefNull file_space_name_get(const ScrArea *area)
|
||||
{
|
||||
SpaceFile *sfile = static_cast<SpaceFile *>(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;
|
||||
|
||||
@@ -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<SpaceGraph *>(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<SpaceGraph *>(area->spacedata.first);
|
||||
return sgraph->mode_prev;
|
||||
}
|
||||
|
||||
static blender::StringRefNull graph_space_name_get(const ScrArea *area)
|
||||
{
|
||||
SpaceGraph *sgraph = static_cast<SpaceGraph *>(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;
|
||||
|
||||
@@ -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<SpaceImage *>(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<SpaceImage *>(area->spacedata.first);
|
||||
return sima->mode_prev;
|
||||
}
|
||||
|
||||
static blender::StringRefNull image_space_name_get(const ScrArea *area)
|
||||
{
|
||||
SpaceImage *sima = static_cast<SpaceImage *>(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;
|
||||
|
||||
@@ -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<SpaceNode *>(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<SpaceNode *>(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<SpaceNode *>(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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user