Skip to content
Permalink
Browse files

Guard against layer nullptr

  • Loading branch information
m-kuhn committed Aug 26, 2018
1 parent 652737d commit ac8eab2fbb2b3bfa7e6fa251119e998a56276d46
Showing with 18 additions and 10 deletions.
  1. +18 −10 src/gui/qgsmaptooladvanceddigitizing.cpp
@@ -123,8 +123,12 @@ void QgsMapToolAdvancedDigitizing::activate()
connect( mCadDockWidget, &QgsAdvancedDigitizingDockWidget::pointChanged, this, &QgsMapToolAdvancedDigitizing::cadPointChanged );
mCadDockWidget->enable();
mSnapToGridCanvasItem = new QgsSnapToGridCanvasItem( mCanvas );
mSnapToGridCanvasItem->setCrs( currentVectorLayer()->crs() );
mSnapToGridCanvasItem->setPrecision( currentVectorLayer()->geometryFixes()->geometryPrecision() );
QgsVectorLayer *layer = currentVectorLayer();
if ( layer )
{
mSnapToGridCanvasItem->setCrs( currentVectorLayer()->crs() );
mSnapToGridCanvasItem->setPrecision( currentVectorLayer()->geometryFixes()->geometryPrecision() );
}
mSnapToGridCanvasItem->setEnabled( mSnapToGridEnabled );
}

@@ -146,16 +150,20 @@ void QgsMapToolAdvancedDigitizing::cadPointChanged( const QgsPointXY &point )

void QgsMapToolAdvancedDigitizing::onCurrentLayerChanged()
{
QgsVectorLayer *layer = currentVectorLayer();
if ( mSnapToGridCanvasItem && layer && mSnapToGridEnabled )
if ( mSnapToGridCanvasItem )
{
mSnapToGridCanvasItem->setPrecision( layer->geometryFixes()->geometryPrecision() );
mSnapToGridCanvasItem->setCrs( layer->crs() );
mSnapToGridCanvasItem->setEnabled( true );
}
QgsVectorLayer *layer = currentVectorLayer();
if ( layer && mSnapToGridEnabled )
{
mSnapToGridCanvasItem->setPrecision( layer->geometryFixes()->geometryPrecision() );
mSnapToGridCanvasItem->setCrs( layer->crs() );
}

if ( !layer )
mSnapToGridCanvasItem->setEnabled( false );
if ( !layer )
mSnapToGridCanvasItem->setEnabled( false );
else
mSnapToGridCanvasItem->setEnabled( mSnapToGridEnabled );
}
}

bool QgsMapToolAdvancedDigitizing::snapToGridEnabled() const

0 comments on commit ac8eab2

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