Skip to content

Commit

Permalink
[attribute table] fix crash when removing layer with show selected fe…
Browse files Browse the repository at this point in the history
…atures
  • Loading branch information
nirvn committed Feb 8, 2018
1 parent 2cbf139 commit 234540f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ void QgsAttributeTableModel::attributeDeleted( int idx )

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

mAttributeWidgetCaches.clear();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 234540f

Please sign in to comment.