diff options
author | Andy Shaw <andy.shaw@qt.io> | 2018-02-03 00:43:09 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2018-02-05 11:28:14 +0000 |
commit | b830bb006a7d8c27cc019b6737c669e96098bc3f (patch) | |
tree | 92b33650d50c18bc24c06a31a41cbac373b52cf9 /src | |
parent | 47f3f659d2c4bae874f78998aece8145605bfd50 (diff) |
When effective marker is MarkerFromSeries then it can call a pure virtual
When MarkerFromSeries was used it would end up crashing due to a pure
virtual call because the QLegendMarkerPrivate subclass had not finished
being created and therefore it would not be able to call series() to
determine the marker shape.
Therefore the call to updateMarkerShapeAndSize() is removed from the
constructor as it will be called via updated() anyway, and to account
for one possible outcome, added to setGeometry() to ensure the items
are valid in time.
Task-number: QTBUG-65616
Change-Id: Iaa50a83373f570d1d41c48a6184c99d4de2b739b
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/charts/legend/legendmarkeritem.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/charts/legend/legendmarkeritem.cpp b/src/charts/legend/legendmarkeritem.cpp index 39ac8b6f..8b83a955 100644 --- a/src/charts/legend/legendmarkeritem.cpp +++ b/src/charts/legend/legendmarkeritem.cpp @@ -62,7 +62,6 @@ LegendMarkerItem::LegendMarkerItem(QLegendMarkerPrivate *marker, QGraphicsObject m_hovering(false), m_itemType(TypeRect) { - updateMarkerShapeAndSize(); m_textItem->document()->setDocumentMargin(ChartPresenter::textMargin()); setAcceptHoverEvents(true); } @@ -147,6 +146,9 @@ QBrush LegendMarkerItem::labelBrush() const void LegendMarkerItem::setGeometry(const QRectF &rect) { + if (!m_markerItem) + updateMarkerShapeAndSize(); + const qreal width = rect.width(); const qreal markerWidth = effectiveMarkerWidth(); const qreal x = m_margin + markerWidth + m_space + m_margin; |