And area-joining is memory-error free again!
This commit is contained in:
Ton Roosendaal 2008-12-14 17:48:52 +00:00
parent ec00764dd2
commit cc51a4f211
3 changed files with 12 additions and 13 deletions

@ -252,10 +252,13 @@ static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v
return sa; return sa;
} }
static void screen_delarea(bScreen *sc, ScrArea *sa) static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa)
{ {
/* XXX need context to cancel operators ED_area_exit(C, sa); */
ED_area_exit(C, sa);
BKE_screen_area_free(sa); BKE_screen_area_free(sa);
BLI_remlink(&sc->areabase, sa); BLI_remlink(&sc->areabase, sa);
MEM_freeN(sa); MEM_freeN(sa);
} }
@ -475,7 +478,7 @@ int area_getorientation(bScreen *screen, ScrArea *sa, ScrArea *sb)
/* Helper function to join 2 areas, it has a return value, 0=failed 1=success /* Helper function to join 2 areas, it has a return value, 0=failed 1=success
* used by the split, join operators * used by the split, join operators
*/ */
int screen_area_join(bScreen* scr, ScrArea *sa1, ScrArea *sa2) int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2)
{ {
int dir; int dir;
@ -514,7 +517,7 @@ int screen_area_join(bScreen* scr, ScrArea *sa1, ScrArea *sa2)
screen_addedge(scr, sa1->v3, sa1->v4); screen_addedge(scr, sa1->v3, sa1->v4);
} }
screen_delarea(scr, sa2); screen_delarea(C, scr, sa2);
removedouble_scrverts(scr); removedouble_scrverts(scr);
sa1->flag &= ~AREA_FLAG_DRAWJOINFROM; sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
@ -567,7 +570,7 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
{ {
ScrVert *sv=NULL; ScrVert *sv=NULL;
ScrArea *sa, *san; ScrArea *sa;
int sizex, sizey; int sizex, sizey;
float facx, facy, tempf, min[2], max[2]; float facx, facy, tempf, min[2], max[2];
@ -616,11 +619,7 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
} }
/* test for collapsed areas. This could happen in some blender version... */ /* test for collapsed areas. This could happen in some blender version... */
for(sa= sc->areabase.first; sa; sa= san) { /* ton: removed option now, it needs Context... */
san= sa->next;
if(sa->v1==sa->v2 || sa->v3==sa->v4 || sa->v2==sa->v3)
screen_delarea(sc, sa);
}
/* make each window at least HEADERY high */ /* make each window at least HEADERY high */
for(sa= sc->areabase.first; sa; sa= sa->next) { for(sa= sc->areabase.first; sa; sa= sa->next) {

@ -38,7 +38,7 @@ void area_copy_data (ScrArea *sa1, ScrArea *sa2, int swap_space);
bScreen *screen_add(struct wmWindow *win, char *name); bScreen *screen_add(struct wmWindow *win, char *name);
ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2); ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2);
ScrArea *area_split(wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac); ScrArea *area_split(wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac);
int screen_area_join(bScreen* scr, ScrArea *sa1, ScrArea *sa2); int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2);
int area_getorientation(bScreen *screen, ScrArea *sa, ScrArea *sb); int area_getorientation(bScreen *screen, ScrArea *sa, ScrArea *sb);
void select_connected_scredge(bScreen *sc, ScrEdge *edge); void select_connected_scredge(bScreen *sc, ScrEdge *edge);

@ -823,7 +823,7 @@ static int area_split_cancel(bContext *C, wmOperator *op)
{ {
sAreaSplitData *sd= (sAreaSplitData *)op->customdata; sAreaSplitData *sd= (sAreaSplitData *)op->customdata;
if (screen_area_join(C->screen,sd->sarea, sd->narea)) { if (screen_area_join(C, C->screen, sd->sarea, sd->narea)) {
if (C->area == sd->narea) { if (C->area == sd->narea) {
C->area = NULL; C->area = NULL;
} }
@ -975,7 +975,7 @@ static int area_join_apply(bContext *C, wmOperator *op)
sAreaJoinData *jd = (sAreaJoinData *)op->customdata; sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
if (!jd) return 0; if (!jd) return 0;
if(!screen_area_join(C->screen,jd->sa1,jd->sa2)){ if(!screen_area_join(C, C->screen, jd->sa1, jd->sa2)){
return 0; return 0;
} }
if (C->area == jd->sa2) { if (C->area == jd->sa2) {