diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-06-10 10:30:22 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-06-10 10:38:27 +0300 |
commit | 3dd93906f007479864adfd7e4962b92a9d85a12d (patch) | |
tree | 09836140a12f6979ed6e6de0d21edb53ecc5e2dc /src/boxplotchart | |
parent | a2f72685ff335e4beb09df76d0513e7f8355a8a8 (diff) |
Further crash fixes to boxplot
Change-Id: Ic14119490bb39a7040d4bed65af4f19548846a89
Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src/boxplotchart')
-rw-r--r-- | src/boxplotchart/qboxplotseries.cpp | 11 | ||||
-rw-r--r-- | src/boxplotchart/qboxset.cpp | 3 | ||||
-rw-r--r-- | src/boxplotchart/qboxset_p.h | 3 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/boxplotchart/qboxplotseries.cpp b/src/boxplotchart/qboxplotseries.cpp index 7635071c..547d086f 100644 --- a/src/boxplotchart/qboxplotseries.cpp +++ b/src/boxplotchart/qboxplotseries.cpp @@ -559,13 +559,14 @@ void QBoxPlotSeriesPrivate::handleSeriesChange(QAbstractSeries *series) bool QBoxPlotSeriesPrivate::append(QBoxSet *set) { - if ((m_boxSets.contains(set)) || (set == 0)) + if (m_boxSets.contains(set) || (set == 0) || set->d_ptr->m_series) return false; // Fail if set is already in list or set is null. m_boxSets.append(set); QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); QObject::connect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes())); QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes())); + set->d_ptr->m_series = this; emit restructuredBoxes(); // this notifies boxplotchartitem return true; @@ -576,6 +577,7 @@ bool QBoxPlotSeriesPrivate::remove(QBoxSet *set) if (!m_boxSets.contains(set)) return false; // Fail if set is not in list + set->d_ptr->m_series = 0; m_boxSets.removeOne(set); QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes())); @@ -588,7 +590,7 @@ bool QBoxPlotSeriesPrivate::remove(QBoxSet *set) bool QBoxPlotSeriesPrivate::append(QList<QBoxSet *> sets) { foreach (QBoxSet *set, sets) { - if ((set == 0) || (m_boxSets.contains(set))) + if ((set == 0) || m_boxSets.contains(set) || set->d_ptr->m_series) return false; // Fail if any of the sets is null or is already appended. if (sets.count(set) != 1) return false; // Also fail if same set is more than once in given list. @@ -599,6 +601,7 @@ bool QBoxPlotSeriesPrivate::append(QList<QBoxSet *> sets) QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); QObject::connect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes())); QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes())); + set->d_ptr->m_series = this; } emit restructuredBoxes(); // this notifies boxplotchartitem @@ -618,6 +621,7 @@ bool QBoxPlotSeriesPrivate::remove(QList<QBoxSet *> sets) } foreach (QBoxSet *set, sets) { + set->d_ptr->m_series = 0; m_boxSets.removeOne(set); QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes())); @@ -631,10 +635,11 @@ bool QBoxPlotSeriesPrivate::remove(QList<QBoxSet *> sets) bool QBoxPlotSeriesPrivate::insert(int index, QBoxSet *set) { - if ((m_boxSets.contains(set)) || (set == 0)) + if ((m_boxSets.contains(set)) || (set == 0) || set->d_ptr->m_series) return false; // Fail if set is already in list or set is null. m_boxSets.insert(index, set); + set->d_ptr->m_series = this; QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout())); QObject::connect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes())); QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes())); diff --git a/src/boxplotchart/qboxset.cpp b/src/boxplotchart/qboxset.cpp index 36b9ee4a..fc47b5be 100644 --- a/src/boxplotchart/qboxset.cpp +++ b/src/boxplotchart/qboxset.cpp @@ -325,7 +325,8 @@ QBoxSetPrivate::QBoxSetPrivate(const QString label, QBoxSet *parent) : QObject(p m_valuesCount(5), m_appendCount(0), m_pen(QPen(Qt::NoPen)), - m_brush(QBrush(Qt::NoBrush)) + m_brush(QBrush(Qt::NoBrush)), + m_series(0) { m_values = new qreal[m_valuesCount]; } diff --git a/src/boxplotchart/qboxset_p.h b/src/boxplotchart/qboxset_p.h index 4891dca3..697c192e 100644 --- a/src/boxplotchart/qboxset_p.h +++ b/src/boxplotchart/qboxset_p.h @@ -38,6 +38,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE +class QBoxPlotSeriesPrivate; + class QBoxSetPrivate : public QObject { Q_OBJECT @@ -71,6 +73,7 @@ private: QBrush m_brush; QBrush m_labelBrush; QFont m_labelFont; + QBoxPlotSeriesPrivate *m_series; friend class QBoxSet; friend class QBoxPlotSeriesPrivate; |