Skip to content
Permalink
Browse files

[attribute table] fix crash when removing layer with show selected fe…

…atures
  • Loading branch information
nirvn committed Feb 8, 2018
1 parent 2cbf139 commit 234540f0c9c953da729da91226716159f9e27b44
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/gui/attributetable/qgsattributetablemodel.cpp
@@ -264,6 +264,7 @@ void QgsAttributeTableModel::attributeDeleted( int idx )

void QgsAttributeTableModel::layerDeleted()
{
mLayerCache = nullptr;
removeRows( 0, rowCount() );

mAttributeWidgetCaches.clear();
@@ -596,7 +597,7 @@ QVariant QgsAttributeTableModel::headerData( int section, Qt::Orientation orient

QVariant QgsAttributeTableModel::data( const QModelIndex &index, int role ) const
{
if ( !index.isValid() ||
if ( !index.isValid() || !layer() ||
( role != Qt::TextAlignmentRole
&& role != Qt::DisplayRole
&& role != Qt::ToolTipRole
@@ -742,7 +743,7 @@ Qt::ItemFlags QgsAttributeTableModel::flags( const QModelIndex &index ) const
if ( !index.isValid() )
return Qt::ItemIsEnabled;

if ( index.column() >= mFieldCount )
if ( index.column() >= mFieldCount || !layer() )
return Qt::NoItemFlags;

Qt::ItemFlags flags = QAbstractTableModel::flags( index );

0 comments on commit 234540f

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