@@ -7023,9 +7023,9 @@ QgsVectorLayer *QgisApp::pasteToNewMemoryVector()
7023
7023
}
7024
7024
}
7025
7025
7026
- QGis::WkbType wkbType = !typeCounts.isEmpty () ? typeCounts.keys ().value ( 0 ) : QGis::WKBPoint ;
7026
+ QGis::WkbType wkbType = !typeCounts.isEmpty () ? typeCounts.keys ().value ( 0 ) : QGis::WKBNoGeometry ;
7027
7027
7028
- QString typeName = QString ( QGis::featureType ( wkbType ) ).remove ( " WKB" );
7028
+ QString typeName = wkbType != QGis::WKBNoGeometry ? QString ( QGis::featureType ( wkbType ) ).remove ( " WKB" ) : " none " ;
7029
7029
7030
7030
typeName += QString ( " ?memoryid=%1" ).arg ( QUuid::createUuid ().toString () );
7031
7031
@@ -7037,10 +7037,6 @@ QgsVectorLayer *QgisApp::pasteToNewMemoryVector()
7037
7037
{
7038
7038
message = tr ( " No features in clipboard." ); // should not happen
7039
7039
}
7040
- else if ( typeCounts.isEmpty () )
7041
- {
7042
- message = tr ( " No features with geometry found, point type layer will be created." );
7043
- }
7044
7040
else if ( typeCounts.size () > 1 )
7045
7041
{
7046
7042
message = tr ( " Multiple geometry types found, features with geometry different from %1 will be created without geometry." ).arg ( typeName );
@@ -7062,7 +7058,8 @@ QgsVectorLayer *QgisApp::pasteToNewMemoryVector()
7062
7058
}
7063
7059
7064
7060
layer->startEditing ();
7065
- layer->setCrs ( clipboard ()->crs (), false );
7061
+ if ( wkbType != QGis::WKBNoGeometry )
7062
+ layer->setCrs ( clipboard ()->crs (), false );
7066
7063
7067
7064
Q_FOREACH ( QgsField f, clipboard ()->fields ().toList () )
7068
7065
{
@@ -7098,13 +7095,12 @@ QgsVectorLayer *QgisApp::pasteToNewMemoryVector()
7098
7095
feature.geometry ()->convertToMultiType ();
7099
7096
}
7100
7097
}
7101
- if ( ! layer->addFeatures ( features ) || !layer->commitChanges () )
7098
+ if ( ! layer->addFeatures ( features, false ) || !layer->commitChanges () )
7102
7099
{
7103
7100
QgsDebugMsg ( " Cannot add features or commit changes" );
7104
7101
delete layer;
7105
7102
return nullptr ;
7106
7103
}
7107
- layer->removeSelection ();
7108
7104
7109
7105
QgsDebugMsg ( QString ( " %1 features pasted to temporary scratch layer" ).arg ( layer->featureCount () ) );
7110
7106
return layer;
0 commit comments