[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14096] trunk/blender/source/blender/src:
Brecht Van Lommel
brechtvanlommel at pandora.be
Thu Mar 13 20:40:38 CET 2008
Revision: 14096
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14096
Author: blendix
Date: 2008-03-13 20:40:36 +0100 (Thu, 13 Mar 2008)
Log Message:
-----------
Two bugfixes:
- Clicking below the list of items in the shift+f4 databrowser could crash.
- Text window crashed when making it zero size.
Modified Paths:
--------------
trunk/blender/source/blender/src/drawtext.c
trunk/blender/source/blender/src/filesel.c
Modified: trunk/blender/source/blender/src/drawtext.c
===================================================================
--- trunk/blender/source/blender/src/drawtext.c 2008-03-13 18:47:55 UTC (rev 14095)
+++ trunk/blender/source/blender/src/drawtext.c 2008-03-13 19:40:36 UTC (rev 14096)
@@ -740,13 +740,13 @@
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 @@
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 @@
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;
Modified: trunk/blender/source/blender/src/filesel.c
===================================================================
--- trunk/blender/source/blender/src/filesel.c 2008-03-13 18:47:55 UTC (rev 14095)
+++ trunk/blender/source/blender/src/filesel.c 2008-03-13 19:40:36 UTC (rev 14096)
@@ -637,7 +637,7 @@
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 @@
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 @@
*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 @@
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;
More information about the Bf-blender-cvs
mailing list