diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-10-26 14:43:27 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-10-26 14:43:27 +0300 |
commit | 32dd928ed6df59f1d0fb91b1f8942a799cada880 (patch) | |
tree | c9be4fb34fa75f48eabb8b2a87871985d634b714 /source/blender/editors/screen | |
parent | 536fe27ba36e0283fb000d19afcf7ca95c3c1de9 (diff) |
Bugfix: opening file browser or starting render with mouse outside
of window could crash, these functions relied too much on context.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 39 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 12 |
3 files changed, 30 insertions, 23 deletions
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 6b71ccaba10..9fb472b674a 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -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; + + if(!sa || sa->full==0) + newsa= ed_screen_fullarea(C, win, sa); + else + newsa= sa; - /* CTX_wm_area(C) is new area */ - ED_area_newspace(C, CTX_wm_area(C), type); + 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 diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index 2b3a816f8de..6278ea8db88 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -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); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 0baadf8d01a..efcbc953456 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -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; } |