diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-03-13 22:40:36 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-03-13 22:40:36 +0300 |
commit | 15215493bf9d1d08e650109e6eb6189fc76e289e (patch) | |
tree | bf04a7c508fca916b22518439b02ab8901c205db /source/blender/src | |
parent | ecc4ccf68f057788cbd1e117672b8531ca7f286f (diff) |
Two bugfixes:
- Clicking below the list of items in the shift+f4 databrowser could crash.
- Text window crashed when making it zero size.
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/drawtext.c | 84 | ||||
-rw-r--r-- | source/blender/src/filesel.c | 12 |
2 files changed, 53 insertions, 43 deletions
diff --git a/source/blender/src/drawtext.c b/source/blender/src/drawtext.c index 22351479883..8ef18ee954e 100644 --- a/source/blender/src/drawtext.c +++ b/source/blender/src/drawtext.c @@ -740,13 +740,13 @@ static void calc_text_rcts(SpaceText *st) ltexth += blank_lines; - barheight = (st->viewlines*pix_available) / ltexth; + barheight = (ltexth > 0)? (st->viewlines*pix_available)/ltexth: 0; pix_bardiff = 0; if (barheight < 20) { pix_bardiff = 20 - barheight; /* take into account the now non-linear sizing of the bar */ barheight = 20; } - barstart = ((pix_available - pix_bardiff) * st->top) / ltexth; + barstart = (ltexth > 0)? ((pix_available - pix_bardiff) * st->top)/ltexth: 0; st->txtbar.xmin = 5; st->txtbar.xmax = 17; @@ -756,7 +756,7 @@ static void calc_text_rcts(SpaceText *st) CLAMP(st->txtbar.ymin, pix_bottom_margin, curarea->winy - pix_top_margin); CLAMP(st->txtbar.ymax, pix_bottom_margin, curarea->winy - pix_top_margin); - st->pix_per_line= (float) ltexth/pix_available; + st->pix_per_line= (pix_available > 0)? (float) ltexth/pix_available: 0; if (st->pix_per_line<.1) st->pix_per_line=.1f; lhlstart = MIN2(txt_get_span(st->text->lines.first, st->text->curl), @@ -764,47 +764,53 @@ static void calc_text_rcts(SpaceText *st) lhlend = MAX2(txt_get_span(st->text->lines.first, st->text->curl), txt_get_span(st->text->lines.first, st->text->sell)); - hlstart = (lhlstart * pix_available) / ltexth; - hlend = (lhlend * pix_available) / ltexth; + if(ltexth > 0) { + hlstart = (lhlstart * pix_available)/ltexth; + hlend = (lhlend * pix_available)/ltexth; - /* the scrollbar is non-linear sized */ - if (pix_bardiff > 0) { - /* the start of the highlight is in the current viewport */ - if (lhlstart >= st->top && lhlstart <= st->top + st->viewlines) { - /* speed the progresion of the start of the highlight through the scrollbar */ - hlstart = ( ( (pix_available - pix_bardiff) * lhlstart) / ltexth) + (pix_bardiff * (lhlstart - st->top) / st->viewlines); - } - else if (lhlstart > st->top + st->viewlines && hlstart < barstart + barheight && hlstart > barstart) { - /* push hl start down */ - hlstart = barstart + barheight; - } - else if (lhlend > st->top && lhlstart < st->top && hlstart > barstart) { - /*fill out start */ - hlstart = barstart; - } + /* the scrollbar is non-linear sized */ + if (pix_bardiff > 0) { + /* the start of the highlight is in the current viewport */ + if (lhlstart >= st->top && lhlstart <= st->top + st->viewlines) { + /* speed the progresion of the start of the highlight through the scrollbar */ + hlstart = ( ( (pix_available - pix_bardiff) * lhlstart) / ltexth) + (pix_bardiff * (lhlstart - st->top) / st->viewlines); + } + else if (lhlstart > st->top + st->viewlines && hlstart < barstart + barheight && hlstart > barstart) { + /* push hl start down */ + hlstart = barstart + barheight; + } + else if (lhlend > st->top && lhlstart < st->top && hlstart > barstart) { + /*fill out start */ + hlstart = barstart; + } - if (hlend <= hlstart) { - hlend = hlstart + 2; - } + if (hlend <= hlstart) { + hlend = hlstart + 2; + } - /* the end of the highlight is in the current viewport */ - if (lhlend >= st->top && lhlend <= st->top + st->viewlines) { - /* speed the progresion of the end of the highlight through the scrollbar */ - hlend = (((pix_available - pix_bardiff )*lhlend)/ltexth) + (pix_bardiff * (lhlend - st->top)/st->viewlines); - } - else if (lhlend < st->top && hlend >= barstart - 2 && hlend < barstart + barheight) { - /* push hl end up */ - hlend = barstart; - } - else if (lhlend > st->top + st->viewlines && lhlstart < st->top + st->viewlines && hlend < barstart + barheight) { - /* fill out end */ - hlend = barstart + barheight; - } + /* the end of the highlight is in the current viewport */ + if (lhlend >= st->top && lhlend <= st->top + st->viewlines) { + /* speed the progresion of the end of the highlight through the scrollbar */ + hlend = (((pix_available - pix_bardiff )*lhlend)/ltexth) + (pix_bardiff * (lhlend - st->top)/st->viewlines); + } + else if (lhlend < st->top && hlend >= barstart - 2 && hlend < barstart + barheight) { + /* push hl end up */ + hlend = barstart; + } + else if (lhlend > st->top + st->viewlines && lhlstart < st->top + st->viewlines && hlend < barstart + barheight) { + /* fill out end */ + hlend = barstart + barheight; + } - if (hlend <= hlstart) { - hlstart = hlend - 2; + if (hlend <= hlstart) { + hlstart = hlend - 2; + } } - } + } + else { + hlstart = 0; + hlend = 0; + } if (hlend - hlstart < 2) { hlend = hlstart + 2; 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->act<sfile->totfile) { 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; |