Fix T52640: crash when opening image file browser in some cases.
There was some invalid state in the screen here, some areas had sa->full set even though no screen was maximized, which then caused a restore from the wrong (empty) area, which then led to spacedata being empty and a crash. This fix properly clears the sa->full after restore, and also fixes existing .blend files in such an invalid state.
This commit is contained in:
parent
584523e0ad
commit
4d8980a690
Notes:
blender-bot
2023-02-14 06:37:03 +01:00
Referenced by issue #52640, Crash when opening and closing image file browser
|
@ -1671,6 +1671,17 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
|
|||
CustomData_set_layer_name(&me->vdata, CD_MDEFORMVERT, 0, "");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
/* Fix for invalid state of screen due to bug in older versions. */
|
||||
for (bScreen *sc = main->screen.first; sc; sc = sc->id.next) {
|
||||
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
|
||||
if(sa->full && sc->state == SCREENNORMAL) {
|
||||
sa->full = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void do_versions_after_linking_270(Main *main)
|
||||
|
|
|
@ -1894,17 +1894,28 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
|
|||
|
||||
if (sa && sa->full) {
|
||||
/* restoring back to SCREENNORMAL */
|
||||
ScrArea *old;
|
||||
|
||||
sc = sa->full; /* the old screen to restore */
|
||||
oldscreen = win->screen; /* the one disappearing */
|
||||
|
||||
sc->state = SCREENNORMAL;
|
||||
|
||||
/* find old area */
|
||||
for (old = sc->areabase.first; old; old = old->next)
|
||||
if (old->full) break;
|
||||
if (old == NULL) {
|
||||
/* find old area to restore from */
|
||||
ScrArea *fullsa;
|
||||
for (ScrArea *old = sc->areabase.first; old; old = old->next) {
|
||||
/* area to restore from is always first */
|
||||
if (old->full && !fullsa) {
|
||||
fullsa = old;
|
||||
}
|
||||
|
||||
/* clear full screen state */
|
||||
old->full = NULL;
|
||||
old->flag &= ~AREA_TEMP_INFO;
|
||||
}
|
||||
|
||||
sa->flag &= ~AREA_TEMP_INFO;
|
||||
sa->full = NULL;
|
||||
|
||||
if (fullsa == NULL) {
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("%s: something wrong in areafullscreen\n", __func__);
|
||||
return NULL;
|
||||
|
@ -1917,9 +1928,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
|
|||
}
|
||||
}
|
||||
|
||||
ED_area_data_swap(old, sa);
|
||||
if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO;
|
||||
old->full = NULL;
|
||||
ED_area_data_swap(fullsa, sa);
|
||||
|
||||
/* animtimer back */
|
||||
sc->animtimer = oldscreen->animtimer;
|
||||
|
|
Loading…
Reference in New Issue