##// END OF EJS Templates
fixed crash in legendmarker when calling update from private constructor
sauimone -
r2227:d68dfe34c17e
parent child
Show More
@@ -158,17 +158,31 void MainWidget::handleMarkerClicked()
158 158
159 159 //![6]
160 160 // Dim the marker, if series is not visible
161 QBrush labelBrush = marker->labelBrush();
162 QColor color = labelBrush.color();
161 qreal alpha = 1.0;
163 162
164 if (marker->series()->isVisible()) {
165 color.setAlphaF(1.0);
166 } else {
167 color.setAlphaF(0.5);
163 if (!marker->series()->isVisible()) {
164 alpha = 0.5;
168 165 }
169 166
170 labelBrush.setColor(color);
171 marker->setLabelBrush(labelBrush);
167 QColor color;
168 QBrush brush = marker->labelBrush();
169 color = brush.color();
170 color.setAlphaF(alpha);
171 brush.setColor(color);
172 marker->setLabelBrush(brush);
173
174 brush = marker->brush();
175 color = brush.color();
176 color.setAlphaF(alpha);
177 brush.setColor(color);
178 marker->setBrush(brush);
179
180 QPen pen = marker->pen();
181 color = pen.color();
182 color.setAlphaF(alpha);
183 pen.setColor(color);
184 marker->setPen(pen);
185
172 186 //![6]
173 187 break;
174 188 }
@@ -46,6 +46,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46 46 QAreaLegendMarker::QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent) :
47 47 QLegendMarker(*new QAreaLegendMarkerPrivate(this,series,legend), parent)
48 48 {
49 d_ptr->updated();
49 50 }
50 51
51 52 /*!
@@ -76,11 +77,11 QAreaSeries* QAreaLegendMarker::series()
76 77
77 78 QAreaLegendMarkerPrivate::QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend) :
78 79 QLegendMarkerPrivate(q,legend),
80 q_ptr(q),
79 81 m_series(series)
80 82 {
81 83 QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
82 84 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
83 updated();
84 85 }
85 86
86 87 QAreaLegendMarkerPrivate::~QAreaLegendMarkerPrivate()
@@ -46,6 +46,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46 46 QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent) :
47 47 QLegendMarker(*new QBarLegendMarkerPrivate(this,series,barset,legend), parent)
48 48 {
49 d_ptr->updated();
49 50 }
50 51
51 52 /*!
@@ -85,13 +86,13 QBarSet* QBarLegendMarker::barset()
85 86
86 87 QBarLegendMarkerPrivate::QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractBarSeries *series, QBarSet *barset, QLegend *legend) :
87 88 QLegendMarkerPrivate(q,legend),
89 q_ptr(q),
88 90 m_series(series),
89 91 m_barset(barset)
90 92 {
91 93 QObject::connect(m_barset, SIGNAL(penChanged()), this, SLOT(updated()));
92 94 QObject::connect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated()));
93 95 QObject::connect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated()));
94 updated();
95 96 }
96 97
97 98 QBarLegendMarkerPrivate::~QBarLegendMarkerPrivate()
@@ -68,7 +68,7 public:
68 68 void invalidateLegend();
69 69
70 70 public Q_SLOTS:
71 virtual void updated() { invalidateLegend(); }
71 virtual void updated() = 0;
72 72
73 73 protected:
74 74 LegendMarkerItem *m_item;
@@ -46,6 +46,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46 46 QPieLegendMarker::QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent) :
47 47 QLegendMarker(*new QPieLegendMarkerPrivate(this,series,slice,legend), parent)
48 48 {
49 d_ptr->updated();
49 50 }
50 51
51 52 /*!
@@ -85,13 +86,13 QPieSlice* QPieLegendMarker::slice()
85 86
86 87 QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend) :
87 88 QLegendMarkerPrivate(q,legend),
89 q_ptr(q),
88 90 m_series(series),
89 91 m_slice(slice)
90 92 {
91 93 QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
92 94 QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
93 95 QObject::connect(m_slice, SIGNAL(penChanged()), this, SLOT(updated()));
94 updated();
95 96 }
96 97
97 98 QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate()
@@ -46,6 +46,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46 46 QXYLegendMarker::QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent) :
47 47 QLegendMarker(*new QXYLegendMarkerPrivate(this,series,legend), parent)
48 48 {
49 d_ptr->updated();
49 50 }
50 51
51 52 /*!
@@ -76,11 +77,11 QXYSeries* QXYLegendMarker::series()
76 77
77 78 QXYLegendMarkerPrivate::QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend) :
78 79 QLegendMarkerPrivate(q,legend),
80 q_ptr(q),
79 81 m_series(series)
80 82 {
81 83 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
82 84 QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated()));
83 updated();
84 85 }
85 86
86 87 QXYLegendMarkerPrivate::~QXYLegendMarkerPrivate()
@@ -114,9 +115,7 void QXYLegendMarkerPrivate::updated()
114 115 }
115 116 } else {
116 117 if (m_item->brush().color() != m_series->pen().color()) {
117 QBrush b = m_item->brush();
118 b.setColor(m_series->pen().color());
119 m_item->setBrush(b);
118 m_item->setBrush(QBrush(m_series->pen().color()));
120 119 brushChanged = true;
121 120 }
122 121 }
General Comments 0
You need to be logged in to leave comments. Login now