mirror of https://github.com/qt/qtgraphs.git
Fix: crash when closing Graphs2D
When series is created outside of graphsview and then added into a graphsview, the app crashes while closing. This seems to be because it ends up calling pure virtual type function from the QAbstractSeries in the getSeriesRendererIndex. This patch adds type variable to QAbstractSeriesPrivate. The variable is set by QAbstractSeriesPrivate constructor. The getSeriesRendererIndex function checks the value of that variable instead of calling the virtual type(). Pick-to: 6.8 6.9 6.10 Fixes: QTBUG-138506 Change-Id: I7aca4970c38cbf83413818b0a77e7cf5d76195b6 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Kaj Grönholm <kaj.gronholm@qt.io>
This commit is contained in:
parent
1367d26953
commit
630b38b3ee
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (C) 2024 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
#include "graphs2d/qabstractseries_p.h"
|
||||
#include <QtGraphs/qareaseries.h>
|
||||
#include <private/qareaseries_p.h>
|
||||
#include <private/qgraphsview_p.h>
|
||||
|
|
@ -472,6 +473,8 @@ void QAreaSeries::setSelectedGradient(QQuickShapeGradient* newSelectedGradient)
|
|||
emit selectedGradientChanged(newSelectedGradient);
|
||||
}
|
||||
|
||||
QAreaSeriesPrivate::QAreaSeriesPrivate() {}
|
||||
QAreaSeriesPrivate::QAreaSeriesPrivate()
|
||||
: QAbstractSeriesPrivate(QAbstractSeries::SeriesType::Area)
|
||||
{}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
#include "graphs2d/qabstractseries_p.h"
|
||||
#include <QtGraphs/qabstractseries.h>
|
||||
#include <QtGraphs/qbarseries.h>
|
||||
#include <QtGraphs/qbarset.h>
|
||||
|
|
@ -1155,16 +1156,17 @@ void QBarSeries::setBarDelegateDirty(bool dirty)
|
|||
}
|
||||
|
||||
QBarSeriesPrivate::QBarSeriesPrivate()
|
||||
: m_barWidth(0.5) // Default value is 50% of category width
|
||||
, m_labelsVisible(false)
|
||||
, m_visible(true)
|
||||
, m_blockBarUpdate(false)
|
||||
, m_labelsFormat()
|
||||
, m_labelsMargin(0)
|
||||
, m_labelsAngle(0)
|
||||
, m_labelsPrecision(6)
|
||||
, m_labelsDirty(true)
|
||||
, m_barDelegateDirty(false)
|
||||
: QAbstractSeriesPrivate(QAbstractSeries::SeriesType::Bar)
|
||||
, m_barWidth(0.5) // Default value is 50% of category width
|
||||
, m_labelsVisible(false)
|
||||
, m_visible(true)
|
||||
, m_blockBarUpdate(false)
|
||||
, m_labelsFormat()
|
||||
, m_labelsMargin(0)
|
||||
, m_labelsAngle(0)
|
||||
, m_labelsPrecision(6)
|
||||
, m_labelsDirty(true)
|
||||
, m_barDelegateDirty(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
#include "graphs2d/xychart/qxyseries_p.h"
|
||||
#include <QtGraphs/qlineseries.h>
|
||||
#include <private/qgraphsview_p.h>
|
||||
#include <private/qlineseries_p.h>
|
||||
|
|
@ -176,7 +177,9 @@ QAbstractSeries::SeriesType QLineSeries::type() const
|
|||
return QAbstractSeries::SeriesType::Line;
|
||||
}
|
||||
|
||||
QLineSeriesPrivate::QLineSeriesPrivate() {}
|
||||
QLineSeriesPrivate::QLineSeriesPrivate()
|
||||
: QXYSeriesPrivate(QAbstractSeries::SeriesType::Line)
|
||||
{}
|
||||
|
||||
/*!
|
||||
\property QLineSeries::width
|
||||
|
|
|
|||
|
|
@ -1198,7 +1198,8 @@ void QPieSeries::setAngleSpanLabelVisibility(QPieSeries::LabelVisibility newAngl
|
|||
}
|
||||
|
||||
QPieSeriesPrivate::QPieSeriesPrivate()
|
||||
: m_pieRelativeHorPos(.5)
|
||||
: QAbstractSeriesPrivate(QAbstractSeries::SeriesType::Pie)
|
||||
, m_pieRelativeHorPos(.5)
|
||||
, m_pieRelativeVerPos(.5)
|
||||
, m_pieRelativeSize(.7)
|
||||
, m_pieStartAngle(0)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
#include "graphs2d/qabstractseries.h"
|
||||
#include <QtGraphs/qabstractseries.h>
|
||||
#include <private/qabstractseries_p.h>
|
||||
#include <private/qgraphsview_p.h>
|
||||
|
|
@ -680,7 +681,8 @@ void QAbstractSeries::componentComplete()
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QAbstractSeriesPrivate::QAbstractSeriesPrivate()
|
||||
QAbstractSeriesPrivate::QAbstractSeriesPrivate(QAbstractSeries::SeriesType type)
|
||||
: m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
//
|
||||
// We mean it.
|
||||
|
||||
#include "graphs2d/qabstractseries.h"
|
||||
#include <QtGraphs/qabstractseries.h>
|
||||
#include <memory>
|
||||
#include <private/qobject_p.h>
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
|
||||
|
|
@ -31,11 +31,15 @@ class QAbstractSeriesPrivate : public QObjectPrivate
|
|||
{
|
||||
Q_DECLARE_PUBLIC(QAbstractSeries)
|
||||
public:
|
||||
explicit QAbstractSeriesPrivate();
|
||||
static QAbstractSeriesPrivate *get(QAbstractSeries *item) { return item->d_func(); }
|
||||
static const QAbstractSeriesPrivate *get(const QAbstractSeries *item) { return item->d_func(); }
|
||||
|
||||
explicit QAbstractSeriesPrivate(QAbstractSeries::SeriesType type);
|
||||
~QAbstractSeriesPrivate() override;
|
||||
|
||||
void setLegendData(const QList<QLegendData> &legendData);
|
||||
void clearLegendData();
|
||||
QAbstractSeries::SeriesType type() { return m_type; }
|
||||
|
||||
static void appendSeriesChildren(QQmlListProperty<QObject> *list, QObject *element);
|
||||
|
||||
|
|
@ -56,6 +60,8 @@ private:
|
|||
|
||||
QAbstractAxis *m_axisX = nullptr;
|
||||
QAbstractAxis *m_axisY = nullptr;
|
||||
|
||||
QAbstractSeries::SeriesType m_type;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
#include "graphs2d/qabstractseries.h"
|
||||
#include "graphs2d/qabstractseries_p.h"
|
||||
#ifdef USE_AREAGRAPH
|
||||
#include <QtGraphs/qareaseries.h>
|
||||
#include <private/arearenderer_p.h>
|
||||
|
|
@ -177,7 +179,7 @@ void QGraphsView::insertSeries(qsizetype index, QObject *object)
|
|||
*/
|
||||
void QGraphsView::removeSeries(QObject *object)
|
||||
{
|
||||
if (auto series = reinterpret_cast<QAbstractSeries *>(object)) {
|
||||
if (auto series = qobject_cast<QAbstractSeries *>(object)) {
|
||||
series->setGraph(nullptr);
|
||||
m_seriesList.removeAll(series);
|
||||
auto &cleanupSeriesList = m_cleanupSeriesList[getSeriesRendererIndex(series)];
|
||||
|
|
@ -1699,7 +1701,7 @@ int QGraphsView::getSeriesRendererIndex(QAbstractSeries *series)
|
|||
{
|
||||
int index = 0;
|
||||
if (series) {
|
||||
switch (series->type()) {
|
||||
switch (QAbstractSeriesPrivate::get(series)->type()) {
|
||||
case QAbstractSeries::SeriesType::Bar:
|
||||
index = 0;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
#include "graphs2d/xychart/qxyseries_p.h"
|
||||
#include <QtGraphs/qscatterseries.h>
|
||||
#include <private/qxypoint_p.h>
|
||||
#include <private/qscatterseries_p.h>
|
||||
|
|
@ -140,6 +141,7 @@ QAbstractSeries::SeriesType QScatterSeries::type() const
|
|||
}
|
||||
|
||||
QScatterSeriesPrivate::QScatterSeriesPrivate()
|
||||
: QXYSeriesPrivate(QAbstractSeries::SeriesType::Scatter)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ void QSplineSeries::setCapStyle(Qt::PenCapStyle newCapStyle)
|
|||
}
|
||||
|
||||
QSplineSeriesPrivate::QSplineSeriesPrivate()
|
||||
: QXYSeriesPrivate()
|
||||
: QXYSeriesPrivate(QAbstractSeries::SeriesType::Spline)
|
||||
, m_width(1.0)
|
||||
, m_capStyle(Qt::PenCapStyle::SquareCap)
|
||||
, m_controlPoints()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
||||
|
||||
#include "graphs2d/qabstractseries.h"
|
||||
#include <QtGraphs/qxyseries.h>
|
||||
#include <private/qxyseries_p.h>
|
||||
#include <private/charthelpers_p.h>
|
||||
|
|
@ -959,7 +960,9 @@ QXYSeries &QXYSeries::operator<< (const QList<QPointF>& points)
|
|||
return *this;
|
||||
}
|
||||
|
||||
QXYSeriesPrivate::QXYSeriesPrivate() {}
|
||||
QXYSeriesPrivate::QXYSeriesPrivate(QAbstractSeries::SeriesType type)
|
||||
: QAbstractSeriesPrivate(type)
|
||||
{}
|
||||
|
||||
void QXYSeriesPrivate::setPointSelected(qsizetype index, bool selected, bool &callSignal)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public:
|
|||
static QXYSeriesPrivate *get(QXYSeries *item) { return item->d_func(); }
|
||||
static const QXYSeriesPrivate *get(const QXYSeries *item) { return item->d_func(); }
|
||||
|
||||
QXYSeriesPrivate();
|
||||
QXYSeriesPrivate(QAbstractSeries::SeriesType type);
|
||||
|
||||
void setPointSelected(qsizetype index, bool selected, bool &callSignal);
|
||||
bool isPointSelected(qsizetype index) const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue