Skip to content

Commit

Permalink
[Backport release-3_10] fix crash with missing layer of a relation (#…
Browse files Browse the repository at this point in the history
…38573)

* fix crash with missing layer of a  relation
  • Loading branch information
qgis-bot committed Sep 3, 2020
1 parent 6aec4e6 commit bca97e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions src/gui/attributetable/qgsfeaturelistview.cpp
Expand Up @@ -230,18 +230,25 @@ void QgsFeatureListView::repaintRequested()

void QgsFeatureListView::mouseMoveEvent( QMouseEvent *event )
{
QPoint pos = event->pos();
if ( mModel )
{
QPoint pos = event->pos();

QModelIndex index = indexAt( pos );
QModelIndex index = indexAt( pos );

if ( mEditSelectionDrag )
{
if ( index.isValid() )
setEditSelection( mModel->mapToMaster( index ), QItemSelectionModel::ClearAndSelect );
if ( mEditSelectionDrag )
{
if ( index.isValid() )
setEditSelection( mModel->mapToMaster( index ), QItemSelectionModel::ClearAndSelect );
}
else
{
selectRow( index, false );
}
}
else
{
selectRow( index, false );
QgsDebugMsg( QStringLiteral( "No model assigned to this view" ) );
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsrelationeditorwidget.cpp
Expand Up @@ -195,7 +195,7 @@ void QgsRelationEditorWidget::setRelationFeature( const QgsRelation &relation, c
// If it is already initialized, it has been set visible before and the currently shown feature is changing
// and the widget needs updating

if ( mVisible )
if ( mVisible && mRelation.isValid() )
{
QgsFeatureRequest myRequest = mRelation.getRelatedFeaturesRequest( mFeature );
mDualView->init( mRelation.referencingLayer(), mEditorContext.mapCanvas(), myRequest, mEditorContext );
Expand Down Expand Up @@ -732,7 +732,7 @@ void QgsRelationEditorWidget::updateUi()

mDualView->init( mNmRelation.referencedLayer(), mEditorContext.mapCanvas(), nmRequest, mEditorContext );
}
else
else if ( mRelation.referencingLayer() )
{
mDualView->init( mRelation.referencingLayer(), mEditorContext.mapCanvas(), myRequest, mEditorContext );
}
Expand Down

0 comments on commit bca97e5

Please sign in to comment.