Skip to content

Commit

Permalink
raise message and return if trying to paste or cut features on not ed…
Browse files Browse the repository at this point in the history
…itable layer

(cherry-pick from 40264ce)
  • Loading branch information
signedav committed Jul 8, 2020
1 parent 40264ce commit 5b01c54
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -10081,6 +10081,14 @@ void QgisApp::cutSelectionToClipboard( QgsMapLayer *layerContainingSelection )
if ( !selectionVectorLayer )
return;

if ( !selectionVectorLayer->isEditable() )
{
visibleMessageBar()->pushMessage( tr( "Layer not editable" ),
tr( "The current layer is not editable. Choose 'Start editing' in the digitizing toolbar." ),
Qgis::Info, messageTimeout() );
return;
}

clipboard()->replaceWithCopyOf( selectionVectorLayer );

selectionVectorLayer->beginEditCommand( tr( "Features cut" ) );
Expand Down Expand Up @@ -10109,6 +10117,14 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer )
if ( !pasteVectorLayer )
return;

if ( !pasteVectorLayer->isEditable() )
{
visibleMessageBar()->pushMessage( tr( "Layer not editable" ),
tr( "The current layer is not editable. Choose 'Start editing' in the digitizing toolbar." ),
Qgis::Info, messageTimeout() );
return;
}

pasteVectorLayer->beginEditCommand( tr( "Features pasted" ) );
QgsFeatureList features = clipboard()->transformedCopyOf( pasteVectorLayer->crs(), pasteVectorLayer->fields() );
int nTotalFeatures = features.count();
Expand Down

0 comments on commit 5b01c54

Please sign in to comment.