Skip to content

Commit

Permalink
Fixes to arrow line symbology:
Browse files Browse the repository at this point in the history
- Fix crash in Python bindings caused by subsymbol ownership
- Make symbol work correctly with categorised and graduated
renderers
  • Loading branch information
nyalldawson committed May 5, 2016
1 parent ca74cc0 commit d75eaff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/core/symbology-ng/qgsarrowsymbollayer.sip
Expand Up @@ -23,7 +23,7 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
virtual QgsSymbolV2* subSymbol();

/** Set the sub symbol used for filling */
virtual bool setSubSymbol( QgsSymbolV2* symbol );
virtual bool setSubSymbol( QgsSymbolV2* symbol /Transfer/ );

/** Return a list of attributes required to render this feature */
virtual QSet<QString> usedAttributes() const;
Expand Down Expand Up @@ -106,6 +106,9 @@ class QgsArrowSymbolLayer : public QgsLineSymbolLayerV2

/** Main drawing method */
void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context );
private:

void setColor( const QColor& c );

private:
QgsArrowSymbolLayer( const QgsArrowSymbolLayer& );
};
9 changes: 9 additions & 0 deletions src/core/symbology-ng/qgsarrowsymbollayer.cpp
Expand Up @@ -45,6 +45,7 @@ bool QgsArrowSymbolLayer::setSubSymbol( QgsSymbolV2* symbol )
mSymbol.reset( static_cast<QgsFillSymbolV2*>( symbol ) );
return true;
}
delete symbol;
return false;
}

Expand Down Expand Up @@ -604,3 +605,11 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2Re
context.renderContext().expressionContext().popScope();
}

void QgsArrowSymbolLayer::setColor( const QColor& c )
{
if ( mSymbol.data() )
mSymbol->setColor( c );

mColor = c;
}

2 changes: 2 additions & 0 deletions src/core/symbology-ng/qgsarrowsymbollayer.h
Expand Up @@ -127,6 +127,8 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
/** Main drawing method */
void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ) override;

void setColor( const QColor& c ) override;

private:
/** Filling sub symbol */
QScopedPointer<QgsFillSymbolV2> mSymbol;
Expand Down

0 comments on commit d75eaff

Please sign in to comment.