Skip to content

Commit

Permalink
Vector tiles: fix crash in gsMapBoxGlStyleConverter::parseFillLayer() (
Browse files Browse the repository at this point in the history
…fixes #41401)

and also a potential similar one in parseLineLayer()

Use default QgsFillSymbol and QgsLineSymbol objects, instead of the default symbols
of the project that might lack a QgsSimpleFillSymbolLayer / QgsSimpleLineSymbolLayer.
Credits to @nyalldawson for this clean fix.
  • Loading branch information
rouault authored and nyalldawson committed Feb 16, 2021
1 parent 0140dd6 commit ba3a54c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/vectortile/qgsmapboxglstyleconverter.cpp
Expand Up @@ -309,8 +309,9 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg
}
}

std::unique_ptr< QgsSymbol > symbol( QgsSymbol::defaultSymbol( QgsWkbTypes::PolygonGeometry ) );
std::unique_ptr< QgsSymbol > symbol( qgis::make_unique< QgsFillSymbol >() );
QgsSimpleFillSymbolLayer *fillSymbol = dynamic_cast< QgsSimpleFillSymbolLayer * >( symbol->symbolLayer( 0 ) );
Q_ASSERT( fillSymbol ); // should not fail since QgsFillSymbol() constructor instantiates a QgsSimpleFillSymbolLayer

// set render units
symbol->setOutputUnit( context.targetUnit() );
Expand Down Expand Up @@ -588,8 +589,9 @@ bool QgsMapBoxGlStyleConverter::parseLineLayer( const QVariantMap &jsonLayer, Qg
}
}

std::unique_ptr< QgsSymbol > symbol( QgsSymbol::defaultSymbol( QgsWkbTypes::LineGeometry ) );
std::unique_ptr< QgsSymbol > symbol( qgis::make_unique< QgsLineSymbol >() );
QgsSimpleLineSymbolLayer *lineSymbol = dynamic_cast< QgsSimpleLineSymbolLayer * >( symbol->symbolLayer( 0 ) );
Q_ASSERT( lineSymbol ); // should not fail since QgsLineSymbol() constructor instantiates a QgsSimpleLineSymbolLayer

// set render units
symbol->setOutputUnit( context.targetUnit() );
Expand Down

0 comments on commit ba3a54c

Please sign in to comment.