mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-04 13:02:09 +08:00
cabana: fix divde by zero for std::log10 (#27077)
fix divde by zero for std::log10 old-commit-hash: 2de2bab2864eeaea8104ac0cbb619c5c25b8b4d6
This commit is contained in:
@@ -332,6 +332,9 @@ ChartView::ChartView(QWidget *parent) : QChartView(nullptr, parent) {
|
||||
}
|
||||
|
||||
qreal ChartView::getYAsixLabelWidth() const {
|
||||
if (axis_y->max() <= axis_y->min() || axis_y->tickCount() <= 1) {
|
||||
return 0;
|
||||
}
|
||||
QFontMetrics fm(axis_y->labelsFont());
|
||||
int n = qMax(int(-qFloor(std::log10((axis_y->max() - axis_y->min()) / (axis_y->tickCount() - 1)))), 0) + 1;
|
||||
return qMax(fm.width(QString::number(axis_y->min(), 'f', n)), fm.width(QString::number(axis_y->max(), 'f', n))) + 20;
|
||||
|
||||
Reference in New Issue
Block a user