Skip to content

Commit

Permalink
Fix a few crashes with bad layers
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Nov 6, 2018
1 parent 1e16680 commit 2dd3f96
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -1140,6 +1140,9 @@ void QgsGpsInformationWidget::updateCloseFeatureButton( QgsMapLayer *lyr )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( lyr );

if ( !( vlayer && vlayer->isValid() ) )
return;

// Add feature button tracks edit state of layer
if ( vlayer != mpLastLayer )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -11298,7 +11298,7 @@ bool QgisApp::checkUnsavedLayerEdits()
{
// note that we skip the unsaved edits check for memory layers -- it's misleading, because their contents aren't actually
// saved if this is part of a project close operation. Instead we let these get picked up by checkMemoryLayers()
if ( vl->dataProvider()->name() == QLatin1String( "memory" ) )
if ( ! vl->dataProvider() || vl->dataProvider()->name() == QLatin1String( "memory" ) )
continue;

const bool hasUnsavedEdits = ( vl->isEditable() && vl->isModified() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgslayertreeviewmemoryindicator.cpp
Expand Up @@ -43,7 +43,7 @@ void QgsLayerTreeViewMemoryIndicatorProvider::onIndicatorClicked( const QModelIn
bool QgsLayerTreeViewMemoryIndicatorProvider::acceptLayer( QgsMapLayer *layer )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
if ( !vlayer )
if ( !( vlayer && vlayer->isValid() ) )
return false;
return vlayer->dataProvider()->name() == QLatin1String( "memory" );
}
Expand Down

0 comments on commit 2dd3f96

Please sign in to comment.