From 9e35a3a169edc2da5384d16add1a55a5c10482e3 2013-04-08 12:50:28 From: Miikka Heikkinen Date: 2013-04-08 12:50:28 Subject: [PATCH] Fix crash when removing pie series from chart Connections cleanup in PieChartItem destructor didn't account for the possibility of series already having been destroyed. Changed m_series to QPointer so that it'll notice when series gets destroyed, and also added cleaning of slices to series destructor. Task-number: QTRD-1946 Change-Id: I651347bfcfbe7cd78dd26220a811fea5c8071fce Reviewed-by: Mika Salmela Reviewed-by: Mika Salmela --- diff --git a/src/piechart/piechartitem_p.h b/src/piechart/piechartitem_p.h index b020e46..68f0e37 100644 --- a/src/piechart/piechartitem_p.h +++ b/src/piechart/piechartitem_p.h @@ -33,6 +33,7 @@ #include "qpieseries.h" #include "chartitem_p.h" #include "piesliceitem_p.h" +#include class QGraphicsItem; QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -71,7 +72,7 @@ private: private: QHash m_sliceItems; - QPieSeries *m_series; + QPointer m_series; QRectF m_rect; QPointF m_pieCenter; qreal m_pieRadius; diff --git a/src/piechart/qpieseries.cpp b/src/piechart/qpieseries.cpp index 13172a1..3a806cf 100644 --- a/src/piechart/qpieseries.cpp +++ b/src/piechart/qpieseries.cpp @@ -362,6 +362,7 @@ QPieSeries::QPieSeries(QObject *parent) QPieSeries::~QPieSeries() { // NOTE: d_prt destroyed by QObject + clear(); } /*!