From 15215493bf9d1d08e650109e6eb6189fc76e289e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 13 Mar 2008 19:40:36 +0000 Subject: Two bugfixes: - Clicking below the list of items in the shift+f4 databrowser could crash. - Text window crashed when making it zero size. --- source/blender/src/filesel.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/blender/src/filesel.c') diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c index 089e37ce51e..597611344c6 100644 --- a/source/blender/src/filesel.c +++ b/source/blender/src/filesel.c @@ -637,7 +637,7 @@ void swapselect_file(SpaceFile *sfile) static int find_active_file(SpaceFile *sfile, short x, short y) { - int ofs; + int ofs, act; if(y > textrct.ymax) y= textrct.ymax; if(y <= textrct.ymin) y= textrct.ymin+1; @@ -646,8 +646,12 @@ static int find_active_file(SpaceFile *sfile, short x, short y) if(ofs<0) ofs= 0; ofs*= (textrct.ymax-textrct.ymin); - return sfile->ofs+ (ofs+textrct.ymax-y)/FILESEL_DY; + act= sfile->ofs+ (ofs+textrct.ymax-y)/FILESEL_DY; + if(act<0 || act>=sfile->totfile) + act= -1; + + return act; } @@ -1453,7 +1457,7 @@ static void filesel_execute(SpaceFile *sfile) *sfile->menup= -1; - if(sfile->act>=0) { + if(sfile->act>=0 && sfile->acttotfile) { if(sfile->filelist) { files= sfile->filelist+sfile->act; if ( strcmp(files->relname, sfile->file)==0) { @@ -2402,7 +2406,7 @@ static void active_file_object(SpaceFile *sfile) if(filesel_has_func(sfile)) return; if( strcmp(sfile->dir, "Object/")==0 ) { - if(sfile->act >= 0) { + if(sfile->act >= 0 && sfile->act < sfile->totfile) { ob= (Object *)sfile->filelist[sfile->act].poin; -- cgit v1.2.3