Ancient bug: when subdividing the screen many times, it gives a crash when

the amount of subwindows reaches 128 (64 areas+headers).

Added a warning instead of crash!
This commit is contained in:
2006-12-26 09:19:19 +00:00
parent 10137426a6
commit e4511c805f
3 changed files with 22 additions and 2 deletions

View File

@@ -99,6 +99,7 @@ void bwin_getsinglematrix(int winid, float mat[][4]);
void bwin_clear_viewmat(int winid);
int myswinopen(int parentid, int xmin, int xmax, int ymin, int ymax);
int myswinopen_allowed(void);
void myswapbuffers(void);
void mygetmatrix(float mat[][4]);

View File

@@ -3011,7 +3011,11 @@ static void splitarea_interactive(ScrArea *area, ScrEdge *onedge)
if(sa->win==0) return;
if(sa->full) return;
if(myswinopen_allowed()==0) {
error("Max amount of subwindows reached");
return;
}
dir= scredge_is_horizontal(onedge)?'v':'h';
mywinset(G.curscreen->mainwin);

View File

@@ -377,11 +377,13 @@ int myswinopen(int parentid, int xmin, int xmax, int ymin, int ymax)
if (!swinarray[freewinid])
break;
/* this case is not handled in Blender, so will crash. use myswinopen_allowed() first to check */
if (freewinid==MAXWIN) {
printf("too many windows\n");
return 0;
} else {
}
else {
win= MEM_callocN(sizeof(*win), "winopen");
win->id= freewinid;
@@ -403,6 +405,19 @@ int myswinopen(int parentid, int xmin, int xmax, int ymin, int ymax)
}
}
int myswinopen_allowed(void)
{
int totfree=0;
int freewinid;
for (freewinid= 4; freewinid<MAXWIN; freewinid++)
if (swinarray[freewinid]==NULL)
totfree++;
if(totfree<2)
return 0;
return 1;
}
void mywinclose(int winid)
{
if (winid<4) {