Fix infinite loop bug in Fl_File_Icon::draw() with 32-bit colors and

outline polygons...


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1665 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2001-10-29 15:40:49 +00:00
parent 46aa6619e1
commit 38fdf727f7

View File

@ -1,5 +1,5 @@
// //
// "$Id: Fl_File_Icon.cxx,v 1.1.2.2 2001/10/29 03:44:32 easysw Exp $" // "$Id: Fl_File_Icon.cxx,v 1.1.2.3 2001/10/29 15:40:49 easysw Exp $"
// //
// Fl_File_Icon routines. // Fl_File_Icon routines.
// //
@ -256,7 +256,8 @@ Fl_File_Icon::draw(int x, // I - Upper-lefthand X
{ {
Fl_Color c, // Current color Fl_Color c, // Current color
oc; // Outline color oc; // Outline color
short *d; // Pointer to data short *d, // Pointer to data
*dend; // End of data...
short *prim; // Pointer to start of primitive... short *prim; // Pointer to start of primitive...
double scale; // Scale of icon double scale; // Scale of icon
@ -275,6 +276,7 @@ Fl_File_Icon::draw(int x, // I - Upper-lefthand X
// Loop through the array until we see an unmatched END... // Loop through the array until we see an unmatched END...
d = data_; d = data_;
dend = data_ + num_data_;
prim = NULL; prim = NULL;
c = ic; c = ic;
@ -283,57 +285,58 @@ Fl_File_Icon::draw(int x, // I - Upper-lefthand X
else else
fl_color(fl_inactive(c)); fl_color(fl_inactive(c));
while (*d != END || prim) while (d < dend)
switch (*d) switch (*d)
{ {
case END : case END :
switch (*prim) if (prim)
{ switch (*prim)
case LINE : {
fl_end_line(); case LINE :
break; fl_end_line();
break;
case CLOSEDLINE : case CLOSEDLINE :
fl_end_loop(); fl_end_loop();
break; break;
case POLYGON : case POLYGON :
fl_end_polygon(); fl_end_polygon();
break; break;
case OUTLINEPOLYGON : case OUTLINEPOLYGON :
fl_end_polygon(); fl_end_polygon();
oc = (Fl_Color)((((unsigned short *)prim)[1] << 16) | oc = (Fl_Color)((((unsigned short *)prim)[1] << 16) |
((unsigned short *)prim)[2]); ((unsigned short *)prim)[2]);
if (active) if (active)
{ {
if (oc == FL_ICON_COLOR) if (oc == FL_ICON_COLOR)
fl_color(ic); fl_color(ic);
else
fl_color(oc);
}
else else
fl_color(oc); {
} if (oc == FL_ICON_COLOR)
else fl_color(fl_inactive(ic));
{ else
if (oc == FL_ICON_COLOR) fl_color(fl_inactive(oc));
fl_color(fl_inactive(ic)); }
else
fl_color(fl_inactive(oc));
}
fl_begin_loop(); fl_begin_loop();
prim += 3;
while (*prim == VERTEX)
{
fl_vertex(prim[1] * 0.0001, prim[2] * 0.0001);
prim += 3; prim += 3;
} while (*prim == VERTEX)
{
fl_vertex(prim[1] * 0.0001, prim[2] * 0.0001);
prim += 3;
}
fl_end_loop(); fl_end_loop();
fl_color(c); fl_color(c);
break; break;
} }
prim = NULL; prim = NULL;
d ++; d ++;
@ -373,7 +376,7 @@ Fl_File_Icon::draw(int x, // I - Upper-lefthand X
case OUTLINEPOLYGON : case OUTLINEPOLYGON :
prim = d; prim = d;
d += 2; d += 3;
fl_begin_polygon(); fl_begin_polygon();
break; break;
@ -382,6 +385,9 @@ Fl_File_Icon::draw(int x, // I - Upper-lefthand X
fl_vertex(d[1] * 0.0001, d[2] * 0.0001); fl_vertex(d[1] * 0.0001, d[2] * 0.0001);
d += 3; d += 3;
break; break;
default : // Ignore invalid data...
d ++;
} }
// If we still have an open primitive, close it... // If we still have an open primitive, close it...
@ -1228,5 +1234,5 @@ get_kde_val(char *str,
// //
// End of "$Id: Fl_File_Icon.cxx,v 1.1.2.2 2001/10/29 03:44:32 easysw Exp $". // End of "$Id: Fl_File_Icon.cxx,v 1.1.2.3 2001/10/29 15:40:49 easysw Exp $".
// //