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 committed Apr 11, 2021
2 parents c8b891b + 6981603 commit 3d249a85b96805ada9a721bf2de55de1a8f13f0a
Showing with 16 additions and 3 deletions.
  1. +6 −0 src/core/raster/qgsrasterlayer.cpp
  2. +10 −3 src/gui/vector/qgsvectorlayerproperties.cpp
@@ -311,6 +311,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 3d249a8

Please sign in to comment.