Workaround/Fix T43139: Calling bpy.ops.screen.screen_full_area() multiple times in python console causes Blender to crash

This was sort of a chicken<->egg dilemma, because after a maximized screen was restored, the screen handling used region
coordinates which weren't updated yet. I'm still not sure why, but this resulted in area coords that go beond INT_MAX.

To fix this I made sure the first screen handling after restoring a maximized screen is skipped, so that it's delayed to
the next call of wm_event_do_handlers (since this is called from main loop there shouldn't be a noticable delay or any
handling glitches).
This commit is contained in:
julianeisel 2015-01-14 01:29:17 +01:00
parent 3d503ea8d6
commit f19013158a
Notes: blender-bot 2023-02-14 09:39:04 +01:00
Referenced by issue #43139, Calling bpy.ops.screen.screen_full_area() multiple times in python console causes Blender to crash
3 changed files with 16 additions and 2 deletions

View File

@ -1881,6 +1881,11 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
BKE_screen_free(oldscreen);
BKE_libblock_free(CTX_data_main(C), oldscreen);
/* After we've restored back to SCREENNORMAL, we have to wait with
* screen handling as it uses the area coords which aren't updated yet.
* Without doing so, the screen handling gets wrong area coords,
* which in worst case can lead to crashes (see T43139) */
sc->skip_handling = true;
}
else {
/* change from SCREENNORMAL to new state */

View File

@ -69,11 +69,12 @@ typedef struct bScreen {
short do_draw_paintcursor; /* notifier for paint cursor draw. */
short do_draw_drag; /* notifier for dragging draw. */
short swap; /* indicator to survive swap-exchange systems */
short skip_handling; /* set to delay screen handling after switching back from maximized area */
short mainwin; /* screensize subwindow, for screenedges and global menus */
short subwinactive; /* active subwindow */
short pad;
double pad;
struct wmTimer *animtimer; /* if set, screen has timer handler added in window */
void *context; /* context callback */
@ -215,7 +216,7 @@ typedef struct ScrArea {
short do_refresh; /* private, for spacetype refresh callback */
short flag;
short region_active_win; /* index of last used region of 'RGN_TYPE_WINDOW'
* runtuime variable, updated by executing operators */
* runtime variable, updated by executing operators */
char temp, pad;
struct SpaceType *type; /* callbacks for this space type */

View File

@ -2318,6 +2318,14 @@ void wm_event_do_handlers(bContext *C)
}
for (sa = win->screen->areabase.first; sa; sa = sa->next) {
/* after restoring a screen from SCREENMAXIMIZED we have to wait
* with the screen handling till the region coordinates are updated */
if (win->screen->skip_handling == true) {
/* restore for the next iteration of wm_event_do_handlers */
win->screen->skip_handling = false;
break;
}
if (wm_event_inside_i(event, &sa->totrct)) {
CTX_wm_area_set(C, sa);