fix: the format buffer is tool small for dso cursor

This commit is contained in:
dreamsourcelabTAI 2024-04-09 16:36:50 +08:00
parent cef911fcc2
commit c37da4cf5d
3 changed files with 8 additions and 8 deletions

View File

@ -105,7 +105,7 @@ Ruler::Ruler(View &parent) :
this, SLOT(hover_point_changed())); this, SLOT(hover_point_changed()));
} }
QString Ruler::format_freq(double period, unsigned precision) QString Ruler::format_freq(double period, unsigned int precision)
{ {
if (period <= 0) { if (period <= 0) {
return View::Unknown_Str; return View::Unknown_Str;
@ -124,8 +124,8 @@ QString Ruler::format_freq(double period, unsigned precision)
return s; return s;
*/ */
char buffer[20] = {0}; char buffer[50] = {0};
char format[10] = {0}; char format[15] = {0};
QString units = FreqPrefixes[prefix] + "Hz"; QString units = FreqPrefixes[prefix] + "Hz";
sprintf(format, "%%.%df", (int)precision); sprintf(format, "%%.%df", (int)precision);
sprintf(buffer, format, 1 / (period * multiplier)); sprintf(buffer, format, 1 / (period * multiplier));
@ -148,8 +148,8 @@ QString Ruler::format_time(double t, int prefix,
return s; return s;
*/ */
char buffer[20] = {0}; char buffer[50];
char format[10] = {0}; char format[15];
QString units = SIPrefixes[prefix] + "s"; QString units = SIPrefixes[prefix] + "s";
double v = (t * multiplier) / 1000000.0; double v = (t * multiplier) / 1000000.0;
buffer[0] = v >= 0 ? '+' : '-'; buffer[0] = v >= 0 ? '+' : '-';

View File

@ -62,7 +62,7 @@ public:
static QString format_time(double t, int prefix, static QString format_time(double t, int prefix,
unsigned precision = pricision); unsigned precision = pricision);
static QString format_freq(double period, unsigned precision = pricision); static QString format_freq(double period, unsigned int precision = pricision);
QString format_time(double t); QString format_time(double t);
static QString format_real_time(uint64_t delta_index, uint64_t sample_rate); static QString format_real_time(uint64_t delta_index, uint64_t sample_rate);
static QString format_real_freq(uint64_t delta_index, uint64_t sample_rate); static QString format_real_freq(uint64_t delta_index, uint64_t sample_rate);

View File

@ -230,8 +230,8 @@ QString SpectrumTrace::format_freq(double freq, unsigned precision)
return s; return s;
*/ */
char buffer[20] = {0}; char buffer[50] = {0};
char format[10] = {0}; char format[15] = {0};
QString units = FreqPrefixes[prefix] + "Hz"; QString units = FreqPrefixes[prefix] + "Hz";
sprintf(format, "%%.%df", (int)precision); sprintf(format, "%%.%df", (int)precision);
sprintf(buffer, format, freq / divider); sprintf(buffer, format, freq / divider);