diff --git a/src/animations/boxplotanimation.cpp b/src/animations/boxplotanimation.cpp index 1bd88d2..a73aa7d 100644 --- a/src/animations/boxplotanimation.cpp +++ b/src/animations/boxplotanimation.cpp @@ -26,7 +26,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item) - : m_item(item) + : QObject(item), + m_item(item) { } @@ -73,6 +74,12 @@ void BoxPlotAnimation::setAnimationStart(BoxWhiskers *box) animation->setStartData(box->m_data); } +void BoxPlotAnimation::stopAll() +{ + foreach (BoxWhiskersAnimation *animation, m_animations.values()) + animation->stopAndDestroyLater(); +} + //#include "moc_boxplotanimation_p.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/animations/boxplotanimation_p.h b/src/animations/boxplotanimation_p.h index 52a38f2..9a64490 100644 --- a/src/animations/boxplotanimation_p.h +++ b/src/animations/boxplotanimation_p.h @@ -39,8 +39,9 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class BoxPlotChartItem; -class BoxPlotAnimation +class BoxPlotAnimation : public QObject { + Q_OBJECT public: BoxPlotAnimation(BoxPlotChartItem *item); ~BoxPlotAnimation(); @@ -50,6 +51,7 @@ public: ChartAnimation *boxChangeAnimation(BoxWhiskers *box); void setAnimationStart(BoxWhiskers *box); + void stopAll(); protected: BoxPlotChartItem *m_item; diff --git a/src/animations/boxwhiskersanimation_p.h b/src/animations/boxwhiskersanimation_p.h index 5e3bd90..975ced3 100644 --- a/src/animations/boxwhiskersanimation_p.h +++ b/src/animations/boxwhiskersanimation_p.h @@ -58,9 +58,7 @@ public: // from QVariantAnimation protected: friend class BoxPlotAnimation; - BoxPlotChartItem *m_item; BoxWhiskers *m_box; - BoxWhiskersData *m_boxData; bool m_moveMedianLine; }; diff --git a/src/boxplotchart/boxplotchartitem.cpp b/src/boxplotchart/boxplotchartitem.cpp index 14e1fad..31c8476 100644 --- a/src/boxplotchart/boxplotchartitem.cpp +++ b/src/boxplotchart/boxplotchartitem.cpp @@ -32,8 +32,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE BoxPlotChartItem::BoxPlotChartItem(QBoxPlotSeries *series, QGraphicsItem *item) : ChartItem(series->d_func(), item), m_series(series), - m_animation(0), - m_animate(0) + m_animation(0) { connect(series, SIGNAL(boxsetsRemoved(QList)), this, SLOT(handleBoxsetRemove(QList))); connect(series->d_func(), SIGNAL(restructuredBoxes()), this, SLOT(handleDataStructureChanged())); diff --git a/src/boxplotchart/boxplotchartitem_p.h b/src/boxplotchart/boxplotchartitem_p.h index 2f64790..869ec3e 100644 --- a/src/boxplotchart/boxplotchartitem_p.h +++ b/src/boxplotchart/boxplotchartitem_p.h @@ -75,7 +75,6 @@ protected: int m_seriesCount; BoxPlotAnimation *m_animation; - bool m_animate; QRectF m_boundingRect; }; diff --git a/src/boxplotchart/qboxplotseries.cpp b/src/boxplotchart/qboxplotseries.cpp index 3bc62cc..7635071 100644 --- a/src/boxplotchart/qboxplotseries.cpp +++ b/src/boxplotchart/qboxplotseries.cpp @@ -488,9 +488,11 @@ void QBoxPlotSeriesPrivate::initializeAnimations(QChart::AnimationOptions option item->animation()->stopAndDestroyLater(); if (options.testFlag(QChart::SeriesAnimations)) - item->setAnimation(new BoxPlotAnimation(item)); + m_animation = new BoxPlotAnimation(item); else - item->setAnimation(0); + m_animation = 0; + item->setAnimation(m_animation); + QAbstractSeriesPrivate::initializeAnimations(options); } @@ -506,7 +508,11 @@ void QBoxPlotSeriesPrivate::handleSeriesRemove(QAbstractSeries *series) Q_Q(QBoxPlotSeries); QBoxPlotSeries *removedSeries = static_cast(series); - QObject::disconnect(m_chart->d_ptr->m_dataset, 0, removedSeries->d_func(), 0); + + if (q == removedSeries && m_animation) { + m_animation->stopAll(); + QObject::disconnect(m_chart->d_ptr->m_dataset, 0, removedSeries->d_func(), 0); + } // Test if series removed is me, then don't do anything if (q != removedSeries) { diff --git a/src/boxplotchart/qboxplotseries_p.h b/src/boxplotchart/qboxplotseries_p.h index fdd8963..5395038 100644 --- a/src/boxplotchart/qboxplotseries_p.h +++ b/src/boxplotchart/qboxplotseries_p.h @@ -37,6 +37,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE +class BoxPlotAnimation; + class QBoxPlotSeriesPrivate : public QAbstractSeriesPrivate { Q_OBJECT @@ -85,6 +87,7 @@ protected: QPen m_pen; QBrush m_brush; int m_index; + BoxPlotAnimation *m_animation; private: Q_DECLARE_PUBLIC(QBoxPlotSeries)