Fix T98925: Editor panels are broken

Commit 277fa2f441 added channels region to unintended editors if sequencer was
used in area. This caused issues with some editors having 2 tool regions and
non functioning side panel.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D15253
This commit is contained in:
Richard Antalik 2022-06-24 10:23:31 +02:00
parent 3323cd9c9a
commit e08c932482
Notes: blender-bot 2023-02-14 06:46:23 +01:00
Referenced by issue #98925, N-panel problem with old version files
Referenced by issue #98661, 3.2: Potential candidates for corrective releases
3 changed files with 48 additions and 4 deletions

View File

@ -439,6 +439,14 @@ void BKE_screen_area_free(struct ScrArea *area);
void BKE_region_callback_free_gizmomap_set(void (*callback)(struct wmGizmoMap *));
void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizmoMap *));
/**
* Find a region of type \a region_type in provided \a regionbase.
*
* \note this is useful for versioning where either the #Area or #SpaceLink regionbase are typical
* inputs
*/
struct ARegion *BKE_region_find_in_listbase_by_type(const struct ListBase *regionbase,
const int region_type);
/**
* Find a region of type \a region_type in the currently active space of \a area.
*

View File

@ -856,6 +856,17 @@ void BKE_screen_remove_unused_scrverts(bScreen *screen)
/* ***************** Utilities ********************** */
ARegion *BKE_region_find_in_listbase_by_type(const ListBase *regionbase, const int region_type)
{
LISTBASE_FOREACH (ARegion *, region, regionbase) {
if (region->regiontype == region_type) {
return region;
}
}
return NULL;
}
ARegion *BKE_area_find_region_type(const ScrArea *area, int region_type)
{
if (area) {

View File

@ -798,13 +798,16 @@ void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports))
continue;
}
SpaceSeq *sseq = (SpaceSeq *)sl;
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
sseq->flag |= SEQ_CLAMP_VIEW;
if (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW)) {
continue;
}
ARegion *timeline_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
ARegion *timeline_region = BKE_region_find_in_listbase_by_type(regionbase,
RGN_TYPE_WINDOW);
if (timeline_region == NULL) {
continue;
@ -2869,16 +2872,19 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_CHANNELS);
ARegion *region = BKE_region_find_in_listbase_by_type(regionbase, RGN_TYPE_CHANNELS);
if (!region) {
ARegion *tools_region = BKE_area_find_region_type(area, RGN_TYPE_TOOLS);
/* Find sequencer tools region. */
ARegion *tools_region = BKE_region_find_in_listbase_by_type(regionbase,
RGN_TYPE_TOOLS);
region = do_versions_add_region(RGN_TYPE_CHANNELS, "channels region");
BLI_insertlinkafter(regionbase, tools_region, region);
region->alignment = RGN_ALIGN_LEFT;
region->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
}
ARegion *timeline_region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
ARegion *timeline_region = BKE_region_find_in_listbase_by_type(regionbase,
RGN_TYPE_WINDOW);
if (timeline_region != NULL) {
timeline_region->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL;
}
@ -3176,5 +3182,24 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
{
/* Keep this block, even when empty. */
/* Fix for T98925 - remove channels region, that was initialized in incorrect editor types. */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_CLIP, SPACE_GRAPH, SPACE_NLA, SPACE_SEQ)) {
continue;
}
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
ARegion *channels_region = BKE_region_find_in_listbase_by_type(regionbase,
RGN_TYPE_CHANNELS);
if (channels_region) {
BLI_freelinkN(regionbase, channels_region);
}
}
}
}
}
}