From faa10209176d04c51575cfb02dbfbde1f94cf748 2012-06-07 11:14:07 From: Marek Rosa Date: 2012-06-07 11:14:07 Subject: [PATCH] Fix to BarSeries animation on BarSets restructured --- diff --git a/src/animations/chartanimator.cpp b/src/animations/chartanimator.cpp index bc9646c..7421124 100644 --- a/src/animations/chartanimator.cpp +++ b/src/animations/chartanimator.cpp @@ -100,13 +100,16 @@ void ChartAnimator::updateAnimation(PieChartItem *item, PieSliceItem *sliceItem, void ChartAnimator::updateLayout(BarChartItem *item, const QVector &oldLayout, const QVector &newLayout) { BarAnimation *animation = static_cast(m_animations.value(item)); - Q_ASSERT(animation); - animation->stop(); + m_animations.remove(item); + if (animation) { + animation->deleteLater(); + animation = 0; + } + addAnimation(item); + animation = static_cast(m_animations.value(item)); animation->setDuration(ChartAnimationDuration); - animation->setStartValue(qVariantFromValue(oldLayout)); animation->setKeyValueAt(0.0, qVariantFromValue(oldLayout)); animation->setKeyValueAt(1.0, qVariantFromValue(newLayout)); - animation->setEndValue(qVariantFromValue(newLayout)); QTimer::singleShot(0, animation, SLOT(start())); } diff --git a/src/barchart/barchartitem.cpp b/src/barchart/barchartitem.cpp index 1c853d0..cee5d6a 100644 --- a/src/barchart/barchartitem.cpp +++ b/src/barchart/barchartitem.cpp @@ -163,7 +163,10 @@ void BarChartItem::applyLayout(const QVector &layout) void BarChartItem::setLayout(const QVector &layout) { - m_layout = layout; + if (layout.count() != m_bars.count()) + return; + + m_layout = layout; for (int i=0; i < m_bars.count(); i++) { m_bars.at(i)->setRect(layout.at(i));