cabana: fix QChart leak (#30369)

fix QChart leak
pull/30371/head
Dean Lee 2 years ago committed by GitHub
parent a46544f708
commit f5279284f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      tools/cabana/chart/chart.cc

@ -25,20 +25,18 @@ const int AXIS_X_TOP_MARGIN = 4;
static inline bool xLessThan(const QPointF &p, float x) { return p.x() < x; } static inline bool xLessThan(const QPointF &p, float x) { return p.x() < x; }
ChartView::ChartView(const std::pair<double, double> &x_range, ChartsWidget *parent) ChartView::ChartView(const std::pair<double, double> &x_range, ChartsWidget *parent)
: charts_widget(parent), tip_label(this), QChartView(nullptr, parent) { : charts_widget(parent), tip_label(this), QChartView(parent) {
series_type = (SeriesType)settings.chart_series_type; series_type = (SeriesType)settings.chart_series_type;
QChart *chart = new QChart(); chart()->setBackgroundVisible(false);
chart->setBackgroundVisible(false);
axis_x = new QValueAxis(this); axis_x = new QValueAxis(this);
axis_y = new QValueAxis(this); axis_y = new QValueAxis(this);
chart->addAxis(axis_x, Qt::AlignBottom); chart()->addAxis(axis_x, Qt::AlignBottom);
chart->addAxis(axis_y, Qt::AlignLeft); chart()->addAxis(axis_y, Qt::AlignLeft);
chart->legend()->layout()->setContentsMargins(0, 0, 0, 0); chart()->legend()->layout()->setContentsMargins(0, 0, 0, 0);
chart->legend()->setShowToolTips(true); chart()->legend()->setShowToolTips(true);
chart->setMargins({0, 0, 0, 0}); chart()->setMargins({0, 0, 0, 0});
axis_x->setRange(x_range.first, x_range.second); axis_x->setRange(x_range.first, x_range.second);
setChart(chart);
createToolButtons(); createToolButtons();
setRubberBand(QChartView::HorizontalRubberBand); setRubberBand(QChartView::HorizontalRubberBand);

Loading…
Cancel
Save