Skip to content
Permalink
Browse files

addVectorLayerPrivate(): avoid crash in the non-nominal case when add…

…ed a layer for a non-existing provider

Backport of master commit 099df0b

Fixes #31304
  • Loading branch information
rouault committed May 26, 2020
1 parent 26646d6 commit 646f76f6215ddbae6fb6002f4b6680c033c22c29
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/app/qgisapp.cpp
@@ -11473,7 +11473,7 @@ QgsVectorLayer *QgisApp::addVectorLayerPrivate( const QString &vectorLayerPath,
{
if ( guiWarning )
{
QString message = layer->dataProvider()->error().message( QgsErrorMessage::Text );
QString message = layer->dataProvider() ? layer->dataProvider()->error().message( QgsErrorMessage::Text ) : tr( "Invalid provider" );
QString msg = tr( "The layer %1 is not a valid layer and can not be added to the map. Reason: %2" ).arg( vectorLayerPath, message );
visibleMessageBar()->pushMessage( tr( "Layer is not valid" ), msg, Qgis::Critical, messageTimeout() );
}

0 comments on commit 646f76f

Please sign in to comment.
You can’t perform that action at this time.