Mercurial > hg > svgui
comparison layer/LinearNumericalScale.cpp @ 864:3ca3b8fbbcee
Correct some really stupid fixed-length string stuff, including a genuine stack overflow that causes a crash on OS/X for certain colour 3d plot data.
author | Chris Cannam |
---|---|
date | Mon, 29 Sep 2014 13:27:13 +0100 |
parents | 1d526ba11a24 |
children | e0f08e108064 |
comparison
equal
deleted
inserted
replaced
863:7c75fae51409 | 864:3ca3b8fbbcee |
---|---|
40 int n = 10; | 40 int n = 10; |
41 | 41 |
42 float val = minf; | 42 float val = minf; |
43 float inc = (maxf - val) / n; | 43 float inc = (maxf - val) / n; |
44 | 44 |
45 char buffer[40]; | 45 const int buflen = 40; |
46 char buffer[buflen]; | |
46 | 47 |
47 int w = getWidth(v, paint) + x0; | 48 int w = getWidth(v, paint) + x0; |
48 | 49 |
49 float round = 1.f; | 50 float round = 1.f; |
50 int dp = 0; | 51 int dp = 0; |
84 if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { | 85 if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { |
85 val += inc; | 86 val += inc; |
86 continue; | 87 continue; |
87 } | 88 } |
88 | 89 |
89 sprintf(buffer, "%.*f", dp, dispval); | 90 snprintf(buffer, buflen, "%.*f", dp, dispval); |
90 | 91 |
91 QString label = QString(buffer); | 92 QString label = QString(buffer); |
92 | 93 |
93 paint.drawLine(w - 5, y, w, y); | 94 paint.drawLine(w - 5, y, w, y); |
94 | 95 |