From 099df0bf3dc9ebd9f26370784bd5cfa65b090985 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 11 Oct 2019 20:06:28 +0200 Subject: [PATCH] addVectorLayerPrivate(): avoid crash in the non-nominal case when added a layer for a non-existing provider --- src/app/qgisapp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 4b2e3fe4059..886dd39d648 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -11395,7 +11395,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() ); }