Merge pull request #32706 from m-kuhn/qgis_point_pattern_fill_fix

Fix freeze when loading point pattern fill with distance 0
This commit is contained in:
Matthias Kuhn 2019-11-07 17:29:26 +01:00 committed by GitHub
commit 706c33644d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 3 deletions

View File

@ -3183,7 +3183,11 @@ void QgsPointPatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext
QImage patternImage( width, height, QImage::Format_ARGB32 );
patternImage.fill( 0 );
if ( patternImage.isNull() )
{
brush.setTextureImage( QImage() );
return;
}
if ( mMarkerSymbol )
{
QPainter p( &patternImage );

View File

@ -527,8 +527,7 @@ void QgsSymbol::drawPreviewIcon( QPainter *painter, QSize size, QgsRenderContext
context->setExpressionContext( expContext );
}
const auto constMLayers = mLayers;
for ( QgsSymbolLayer *layer : constMLayers )
for ( QgsSymbolLayer *layer : qgis::as_const( mLayers ) )
{
if ( !layer->enabled() || ( customContext && !customContext->isSymbolLayerEnabled( layer ) ) )
continue;

View File

@ -56,6 +56,7 @@ class TestQgsPointPatternFillSymbol : public QObject
void pointPatternFillSymbol();
void offsettedPointPatternFillSymbol();
void dataDefinedSubSymbol();
void zeroSpacedPointPatternFillSymbol();
private:
bool mTestHasError = false ;
@ -185,6 +186,25 @@ void TestQgsPointPatternFillSymbol::dataDefinedSubSymbol()
QVERIFY( imageCheck( "datadefined_subsymbol" ) );
}
void TestQgsPointPatternFillSymbol::zeroSpacedPointPatternFillSymbol()
{
mReport += QLatin1String( "<h2>Zero distance point pattern fill symbol renderer test</h2>\n" );
QgsStringMap properties;
properties.insert( QStringLiteral( "color" ), QStringLiteral( "0,0,0,255" ) );
properties.insert( QStringLiteral( "outline_color" ), QStringLiteral( "#000000" ) );
properties.insert( QStringLiteral( "name" ), QStringLiteral( "circle" ) );
properties.insert( QStringLiteral( "size" ), QStringLiteral( "5.0" ) );
QgsMarkerSymbol *pointSymbol = QgsMarkerSymbol::createSimple( properties );
mPointPatternFill->setSubSymbol( pointSymbol );
mPointPatternFill->setDistanceX( 0 );
mPointPatternFill->setDistanceY( 15 );
mPointPatternFill->setOffsetX( 4 );
mPointPatternFill->setOffsetY( 4 );
QVERIFY( imageCheck( "pointfill_zero_space" ) );
}
//
// Private helper functions not called directly by CTest
//

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 KiB