Bugfix: opening file browser or starting render with mouse outside
of window could crash, these functions relied too much on context.
This commit is contained in:
@@ -1404,18 +1404,15 @@ void ED_screen_delete_scene(bContext *C, Scene *scene)
|
||||
}
|
||||
|
||||
/* this function toggles: if area is full then the parent will be restored */
|
||||
void ed_screen_fullarea(bContext *C, ScrArea *sa)
|
||||
ScrArea *ed_screen_fullarea(bContext *C, wmWindow *win, ScrArea *sa)
|
||||
{
|
||||
bScreen *sc, *oldscreen;
|
||||
|
||||
if(sa==NULL) {
|
||||
return;
|
||||
}
|
||||
else if(sa->full) {
|
||||
if(sa && sa->full) {
|
||||
short fulltype;
|
||||
|
||||
sc= sa->full; /* the old screen to restore */
|
||||
oldscreen= CTX_wm_screen(C); /* the one disappearing */
|
||||
oldscreen= win->screen; /* the one disappearing */
|
||||
|
||||
fulltype = sc->full;
|
||||
|
||||
@@ -1455,14 +1452,14 @@ void ed_screen_fullarea(bContext *C, ScrArea *sa)
|
||||
else {
|
||||
ScrArea *newa;
|
||||
|
||||
oldscreen= CTX_wm_screen(C);
|
||||
oldscreen= win->screen;
|
||||
|
||||
/* is there only 1 area? */
|
||||
if(oldscreen->areabase.first==oldscreen->areabase.last) return;
|
||||
|
||||
oldscreen->full = SCREENFULL;
|
||||
|
||||
sc= ED_screen_add(CTX_wm_window(C), CTX_data_scene(C), "temp");
|
||||
sc= ED_screen_add(win, oldscreen->scene, "temp");
|
||||
sc->full = SCREENFULL; // XXX
|
||||
|
||||
/* timer */
|
||||
@@ -1470,9 +1467,14 @@ void ed_screen_fullarea(bContext *C, ScrArea *sa)
|
||||
oldscreen->animtimer= NULL;
|
||||
|
||||
/* returns the top small area */
|
||||
newa= area_split(CTX_wm_window(C), sc, (ScrArea *)sc->areabase.first, 'h', 0.99f);
|
||||
newa= area_split(win, sc, (ScrArea *)sc->areabase.first, 'h', 0.99f);
|
||||
ED_area_newspace(C, newa, SPACE_INFO);
|
||||
|
||||
/* use random area when we have no active one, e.g. when the
|
||||
mouse is outside of the window and we open a file browser */
|
||||
if(!sa)
|
||||
sa= oldscreen->areabase.first;
|
||||
|
||||
/* copy area */
|
||||
newa= newa->prev;
|
||||
area_copy_data(newa, sa, 1); /* 1 = swap spacelist */
|
||||
@@ -1489,30 +1491,33 @@ void ed_screen_fullarea(bContext *C, ScrArea *sa)
|
||||
|
||||
/* XXX retopo_force_update(); */
|
||||
|
||||
return sc->areabase.first;
|
||||
}
|
||||
|
||||
int ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
|
||||
{
|
||||
if(sa==NULL)
|
||||
return 0;
|
||||
|
||||
if(sa->full==0)
|
||||
ed_screen_fullarea(C, sa);
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
ScrArea *newsa= NULL;
|
||||
|
||||
/* CTX_wm_area(C) is new area */
|
||||
ED_area_newspace(C, CTX_wm_area(C), type);
|
||||
if(!sa || sa->full==0)
|
||||
newsa= ed_screen_fullarea(C, win, sa);
|
||||
else
|
||||
newsa= sa;
|
||||
|
||||
ED_area_newspace(C, newsa, type);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ED_screen_full_prevspace(bContext *C)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
|
||||
ED_area_prevspace(C);
|
||||
|
||||
if(sa->full)
|
||||
ed_screen_fullarea(C, sa);
|
||||
ed_screen_fullarea(C, win, sa);
|
||||
}
|
||||
|
||||
/* redraws: uses defines from stime->redraws
|
||||
|
||||
@@ -51,7 +51,7 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my);
|
||||
|
||||
AZone *is_in_area_actionzone(ScrArea *sa, int x, int y);
|
||||
|
||||
void ed_screen_fullarea(bContext *C, ScrArea *sa);
|
||||
ScrArea *ed_screen_fullarea(bContext *C, wmWindow *win, ScrArea *sa);
|
||||
|
||||
/* screen_context.c */
|
||||
void ed_screen_context(const bContext *C, const char *member, bContextDataResult *result);
|
||||
|
||||
@@ -1577,7 +1577,7 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot)
|
||||
/* function to be called outside UI context, or for redo */
|
||||
static int screen_full_area_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
ed_screen_fullarea(C, CTX_wm_area(C));
|
||||
ed_screen_fullarea(C, CTX_wm_window(C), CTX_wm_area(C));
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -2576,6 +2576,7 @@ static ScrArea *find_empty_image_area(bContext *C)
|
||||
/* new window uses x,y to set position */
|
||||
static void screen_set_image_output(bContext *C, int mx, int my)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
ScrArea *sa= NULL;
|
||||
SpaceImage *sima;
|
||||
@@ -2592,8 +2593,8 @@ static void screen_set_image_output(bContext *C, int mx, int my)
|
||||
if(sizey < 256) sizey= 256;
|
||||
|
||||
/* XXX some magic to calculate postition */
|
||||
rect.xmin= mx + CTX_wm_window(C)->posx - sizex/2;
|
||||
rect.ymin= my + CTX_wm_window(C)->posy - sizey/2;
|
||||
rect.xmin= mx + win->posx - sizex/2;
|
||||
rect.ymin= my + win->posy - sizey/2;
|
||||
rect.xmax= rect.xmin + sizex;
|
||||
rect.ymax= rect.ymin + sizey;
|
||||
|
||||
@@ -2645,7 +2646,7 @@ static void screen_set_image_output(bContext *C, int mx, int my)
|
||||
if(sa->full) {
|
||||
sima->flag |= SI_FULLWINDOW|SI_PREVSPACE;
|
||||
|
||||
// ed_screen_fullarea(C, sa);
|
||||
// ed_screen_fullarea(C, win, sa);
|
||||
}
|
||||
// }
|
||||
|
||||
@@ -3015,6 +3016,7 @@ static void SCREEN_OT_render(wmOperatorType *ot)
|
||||
|
||||
static int render_view_cancel_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
SpaceImage *sima= sa->spacedata.first;
|
||||
|
||||
@@ -3038,7 +3040,7 @@ static int render_view_cancel_exec(bContext *C, wmOperator *unused)
|
||||
}
|
||||
else if(sima->flag & SI_FULLWINDOW) {
|
||||
sima->flag &= ~SI_FULLWINDOW;
|
||||
ed_screen_fullarea(C, sa);
|
||||
ed_screen_fullarea(C, win, sa);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user