mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
When creating a new annotation layer, ensure it has a unique name
Otherwise things get a bit confusing!
This commit is contained in:
parent
62121258c6
commit
524c431f4c
@ -8771,8 +8771,17 @@ void QgisApp::diagramProperties()
|
||||
|
||||
void QgisApp::createAnnotationLayer()
|
||||
{
|
||||
// pick a unique name for the layer
|
||||
QString name = tr( "Annotations" );
|
||||
int id = 1;
|
||||
while ( !QgsProject::instance()->mapLayersByName( name ).isEmpty() )
|
||||
{
|
||||
name = tr( "Annotations (%1)" ).arg( id );
|
||||
id++;
|
||||
}
|
||||
|
||||
QgsAnnotationLayer::LayerOptions options( QgsProject::instance()->transformContext() );
|
||||
QgsAnnotationLayer *layer = new QgsAnnotationLayer( tr( "Annotations" ), options );
|
||||
QgsAnnotationLayer *layer = new QgsAnnotationLayer( name, options );
|
||||
layer->setCrs( QgsProject::instance()->crs() );
|
||||
|
||||
// layer should be created at top of layer tree
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user