From e4511c805fa3cdebb33f321963fcdb46cc0c4aea Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 26 Dec 2006 09:19:19 +0000 Subject: [PATCH] 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! --- source/blender/include/BIF_mywindow.h | 1 + source/blender/src/editscreen.c | 6 +++++- source/blender/src/mywindow.c | 17 ++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/source/blender/include/BIF_mywindow.h b/source/blender/include/BIF_mywindow.h index 3ef28cc039f..c5456ab7dd5 100644 --- a/source/blender/include/BIF_mywindow.h +++ b/source/blender/include/BIF_mywindow.h @@ -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]); diff --git a/source/blender/src/editscreen.c b/source/blender/src/editscreen.c index a8551656343..e7683580dc4 100644 --- a/source/blender/src/editscreen.c +++ b/source/blender/src/editscreen.c @@ -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); diff --git a/source/blender/src/mywindow.c b/source/blender/src/mywindow.c index f211558bacf..c30fc910fc6 100644 --- a/source/blender/src/mywindow.c +++ b/source/blender/src/mywindow.c @@ -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