Skip to content
Permalink
Browse files

Vector tiles: fix crash in gsMapBoxGlStyleConverter::parseFillLayer() (

…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 ba3a54c77d7c4c3e270b601ad322c63f0aeb8200
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/core/vectortile/qgsmapboxglstyleconverter.cpp
@@ -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() );
@@ -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() );

0 comments on commit ba3a54c

Please sign in to comment.