diff --git a/src/common/QskGradient.cpp b/src/common/QskGradient.cpp index 5ac0554f..20f52daf 100644 --- a/src/common/QskGradient.cpp +++ b/src/common/QskGradient.cpp @@ -317,8 +317,17 @@ void QskGradient::setStops( const QskGradientStops& stops ) m_isDirty = true; } -QskGradientStops QskGradient::stops() const +const QskGradientStops& QskGradient::stops() const { +#if 1 + /* + Returning a const& so that it is possible to write: + for ( const auto& stop : qAsConst( gradient.stops() ) ) + + Once we have changed QskGradientStop from QColor to QRgb + we should check if there is a better solution possible + */ +#endif return m_stops; } diff --git a/src/common/QskGradient.h b/src/common/QskGradient.h index c0544bfd..de97db9c 100644 --- a/src/common/QskGradient.h +++ b/src/common/QskGradient.h @@ -76,7 +76,7 @@ class QSK_EXPORT QskGradient Q_INVOKABLE QColor endColor() const; Q_INVOKABLE void setStops( const QVector< QskGradientStop >& ); - Q_INVOKABLE QVector< QskGradientStop > stops() const; + Q_INVOKABLE const QVector< QskGradientStop >& stops() const; Q_INVOKABLE bool hasStopAt( qreal value ) const; diff --git a/src/nodes/QskArcNode.cpp b/src/nodes/QskArcNode.cpp index c57f6f40..532375a7 100644 --- a/src/nodes/QskArcNode.cpp +++ b/src/nodes/QskArcNode.cpp @@ -36,7 +36,7 @@ uint QskArcNode::hash() const { uint h = m_metrics.hash(); - for( const auto& stop : m_gradient.stops() ) + for( const auto& stop : qAsConst( m_gradient.stops() ) ) h = stop.hash( h ); return h; diff --git a/src/nodes/QskArcRenderer.cpp b/src/nodes/QskArcRenderer.cpp index 28c96580..5cc21283 100644 --- a/src/nodes/QskArcRenderer.cpp +++ b/src/nodes/QskArcRenderer.cpp @@ -18,7 +18,7 @@ void QskArcRenderer::renderArc(const QRectF& rect, QGradientStops stops; - for( const QskGradientStop& stop : gradient.stops() ) + for( const QskGradientStop& stop : qAsConst( gradient.stops() ) ) { QGradientStop s( stop.position(), stop.color() ); stops.append( s ); diff --git a/src/nodes/QskBoxRendererRect.cpp b/src/nodes/QskBoxRendererRect.cpp index 13d22cd8..63c82034 100644 --- a/src/nodes/QskBoxRendererRect.cpp +++ b/src/nodes/QskBoxRendererRect.cpp @@ -434,7 +434,7 @@ static inline void qskCreateBorder( const qreal dy1 = in.top - in.bottom; const qreal dy2 = out.top - out.bottom; - for( const auto& stop : gradientBottom.stops() ) + for( const auto& stop : qAsConst( gradientBottom.stops() ) ) { const Color c( stop.color() ); const qreal x1 = in.right - stop.position() * dx1; @@ -445,7 +445,7 @@ static inline void qskCreateBorder( ( line++ )->setLine( x1, y1, x2, y2, c ); } - for( const auto& stop : gradientLeft.stops() ) + for( const auto& stop : qAsConst( gradientLeft.stops() ) ) { const Color c( stop.color() ); const qreal x1 = in.left; @@ -456,7 +456,7 @@ static inline void qskCreateBorder( ( line++ )->setLine( x1, y1, x2, y2, c ); } - for( const auto& stop : gradientTop.stops() ) + for( const auto& stop : qAsConst( gradientTop.stops() ) ) { const Color c( stop.color() ); const qreal x1 = in.left + stop.position() * dx1; @@ -467,7 +467,7 @@ static inline void qskCreateBorder( ( line++ )->setLine( x1, y1, x2, y2, c ); } - for( const auto& stop : gradientRight.stops() ) + for( const auto& stop : qAsConst( gradientRight.stops() ) ) { const Color c( stop.color() ); const qreal x1 = in.right;