Skip to content
Permalink
Browse files
Merge pull request #42754 from rouault/fix_crash_bad_vector_layer
Gui: fix crash when opening vector layer property dialog on a bad layer
  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2021
1 parent fc40b4d commit 178f6a1a4b40d2c2b127acff25b14846f6a58cc8
Showing with 16 additions and 3 deletions.
  1. +6 −0 src/core/raster/qgsrasterlayer.cpp
  2. +10 −3 src/gui/vector/qgsvectorlayerproperties.cpp
@@ -312,6 +312,9 @@ QgsLegendColorList QgsRasterLayer::legendSymbologyItems() const

QString QgsRasterLayer::htmlMetadata() const
{
if ( !mDataProvider )
return QString();

QgsLayerMetadataFormatter htmlFormatter( metadata() );
QString myMetadata = QStringLiteral( "<html><head></head>\n<body>\n" );

@@ -2173,6 +2176,9 @@ bool QgsRasterLayer::writeXml( QDomNode &layer_node,
QDomDocument &document,
const QgsReadWriteContext &context ) const
{
if ( !mDataProvider )
return false;

// first get the layer element so that we can append the type attribute

QDomElement mapLayerNode = layer_node.toElement();
@@ -944,7 +944,10 @@ void QgsVectorLayerProperties::loadDefaultStyle_clicked()
QString msg;
bool defaultLoadedFlag = false;

if ( mLayer->dataProvider()->isSaveAndLoadStyleToDatabaseSupported() )
const QgsVectorDataProvider *provider = mLayer->dataProvider();
if ( !provider )
return;
if ( provider->isSaveAndLoadStyleToDatabaseSupported() )
{
QMessageBox askToUser;
askToUser.setText( tr( "Load default style from: " ) );
@@ -999,7 +1002,10 @@ void QgsVectorLayerProperties::saveDefaultStyle_clicked()
{
apply();
QString errorMsg;
if ( mLayer->dataProvider()->isSaveAndLoadStyleToDatabaseSupported() )
const QgsVectorDataProvider *provider = mLayer->dataProvider();
if ( !provider )
return;
if ( provider->isSaveAndLoadStyleToDatabaseSupported() )
{
QMessageBox askToUser;
askToUser.setText( tr( "Save default style to: " ) );
@@ -1857,7 +1863,8 @@ void QgsVectorLayerProperties::optionsStackedWidget_CurrentChanged( int index )

void QgsVectorLayerProperties::mSimplifyDrawingGroupBox_toggled( bool checked )
{
if ( !( mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::SimplifyGeometries ) )
const QgsVectorDataProvider *provider = mLayer->dataProvider();
if ( !( provider && ( provider->capabilities() & QgsVectorDataProvider::SimplifyGeometries ) != 0 ) )
{
mSimplifyDrawingAtProvider->setEnabled( false );
}

0 comments on commit 178f6a1

Please sign in to comment.