diff --git a/src/app/legend/qgslegend.cpp b/src/app/legend/qgslegend.cpp index 48fb65a89e5..f3fe37f306c 100644 --- a/src/app/legend/qgslegend.cpp +++ b/src/app/legend/qgslegend.cpp @@ -1172,7 +1172,8 @@ void QgsLegend::removeGroup( QgsLegendGroup *lg ) QgsLegendGroup *cg = dynamic_cast( child ); if ( cl ) - QgsMapLayerRegistry::instance()->removeMapLayer( cl->layer()->id() ); + QgsMapLayerRegistry::instance()->removeMapLayers( + QStringList() << cl->layer()->id() ); else if ( cg ) removeGroup( cg ); @@ -2420,7 +2421,8 @@ void QgsLegend::removeSelectedLayers() QgsLegendLayer *ll = dynamic_cast( item ); if ( ll && ll->layer() ) { - QgsMapLayerRegistry::instance()->removeMapLayer( ll->layer()->id() ); + QgsMapLayerRegistry::instance()->removeMapLayers( + QStringList() << ll->layer()->id() ); continue; } } diff --git a/src/app/qgsnewspatialitelayerdialog.cpp b/src/app/qgsnewspatialitelayerdialog.cpp index 2e300e65aaa..12da4fb4248 100644 --- a/src/app/qgsnewspatialitelayerdialog.cpp +++ b/src/app/qgsnewspatialitelayerdialog.cpp @@ -429,7 +429,11 @@ bool QgsNewSpatialiteLayerDialog::apply() if ( layer->isValid() ) { // register this layer with the central layers registry - if ( QgsMapLayerRegistry::instance()->addMapLayer( layer ) ) + QList myList; + myList << layer; + //addMapLayers returns a list of all successfully added layers + //so we compare that to our original list. + if ( myList == QgsMapLayerRegistry::instance()->addMapLayers( myList ) ) return true; } else diff --git a/src/browser/qgsbrowser.cpp b/src/browser/qgsbrowser.cpp index ce54ebe7872..eb4108b579d 100644 --- a/src/browser/qgsbrowser.cpp +++ b/src/browser/qgsbrowser.cpp @@ -245,7 +245,8 @@ bool QgsBrowser::layerClicked( QgsLayerItem *item ) QgsDebugMsg( "Layer created" ); - QgsMapLayerRegistry::instance()->addMapLayer( mLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mLayer ); return true; } diff --git a/src/core/qgspluginlayerregistry.cpp b/src/core/qgspluginlayerregistry.cpp index 50b64dbe758..21a1cec8638 100644 --- a/src/core/qgspluginlayerregistry.cpp +++ b/src/core/qgspluginlayerregistry.cpp @@ -100,7 +100,8 @@ bool QgsPluginLayerRegistry::removePluginLayerType( QString typeName ) QgsPluginLayer* pl = qobject_cast( layer ); if ( pl->pluginLayerType() == typeName ) { - QgsMapLayerRegistry::instance()->removeMapLayer( layer->id() ); + QgsMapLayerRegistry::instance()->removeMapLayers( + QStringList() << layer->id() ); } } } diff --git a/src/mapserver/qgswmsserver.cpp b/src/mapserver/qgswmsserver.cpp index 9cd9074c2d2..254914074cc 100644 --- a/src/mapserver/qgswmsserver.cpp +++ b/src/mapserver/qgswmsserver.cpp @@ -1427,7 +1427,8 @@ QStringList QgsWMSServer::layerSet( const QStringList &layersList, if ( theMapLayer ) { layerKeys.push_front( theMapLayer->id() ); - QgsMapLayerRegistry::instance()->addMapLayer( theMapLayer, false ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << theMapLayer, false ); } else { diff --git a/src/plugins/georeferencer/qgsgeorefplugingui.cpp b/src/plugins/georeferencer/qgsgeorefplugingui.cpp index 992aba2694e..50a808f7790 100644 --- a/src/plugins/georeferencer/qgsgeorefplugingui.cpp +++ b/src/plugins/georeferencer/qgsgeorefplugingui.cpp @@ -146,7 +146,8 @@ QgsGeorefPluginGui::~QgsGeorefPluginGui() // delete layer (and don't signal it as it's our private layer) if ( mLayer ) { - QgsMapLayerRegistry::instance()->removeMapLayer( mLayer->id(), false ); + QgsMapLayerRegistry::instance()->removeMapLayers( + (QStringList() << mLayer->id()), false ); } delete mToolZoomIn; @@ -251,7 +252,8 @@ void QgsGeorefPluginGui::openRaster() //delete any old rasterlayers if ( mLayer ) - QgsMapLayerRegistry::instance()->removeMapLayer( mLayer->id(), false ); + QgsMapLayerRegistry::instance()->removeMapLayers( + QStringList() << mLayer->id(), false ); // Add raster addRaster( mRasterFileName ); @@ -1039,7 +1041,8 @@ void QgsGeorefPluginGui::addRaster( QString file ) mLayer = new QgsRasterLayer( file, "Raster" ); // so layer is not added to legend - QgsMapLayerRegistry::instance()->addMapLayer( mLayer, false ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mLayer, false ); // add layer to map canvas QList layers; diff --git a/src/plugins/offline_editing/offline_editing.cpp b/src/plugins/offline_editing/offline_editing.cpp index e0f187fb94d..14e31c33ab0 100644 --- a/src/plugins/offline_editing/offline_editing.cpp +++ b/src/plugins/offline_editing/offline_editing.cpp @@ -182,7 +182,8 @@ void QgsOfflineEditing::synchronize( QgsLegendInterface* legendInterface ) copySymbology( offlineLayer, remoteLayer ); // register this layer with the central layers registry - QgsMapLayerRegistry::instance()->addMapLayer( remoteLayer, true ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << remoteLayer, true ); // apply layer edit log QString qgisLayerId = layer->id(); @@ -233,7 +234,8 @@ void QgsOfflineEditing::synchronize( QgsLegendInterface* legendInterface ) } // remove offline layer - QgsMapLayerRegistry::instance()->removeMapLayer( qgisLayerId, true ); + QgsMapLayerRegistry::instance()->removeMapLayers( + (QStringList() << qgisLayerId), true ); // disable offline project QString projectTitle = QgsProject::instance()->title(); @@ -495,7 +497,8 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con } // register this layer with the central layers registry - QgsMapLayerRegistry::instance()->addMapLayer( newLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << newLayer ); if ( hasLabels ) { @@ -567,7 +570,8 @@ void QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlite3* db, con } // remove remote layer - QgsMapLayerRegistry::instance()->removeMapLayer( layer->id() ); + QgsMapLayerRegistry::instance()->removeMapLayers( + QStringList() << layer->id() ); } } } diff --git a/src/plugins/roadgraph/exportdlg.cpp b/src/plugins/roadgraph/exportdlg.cpp index 8f4a7255de0..b05b8d6be00 100644 --- a/src/plugins/roadgraph/exportdlg.cpp +++ b/src/plugins/roadgraph/exportdlg.cpp @@ -85,7 +85,9 @@ QgsVectorLayer* RgExportDlg::mapLayer() const QList attrList; attrList.append( QgsField( "one", QVariant::Int ) ); prov->addAttributes( attrList ); - QgsMapLayerRegistry::instance()->addMapLayer( myLayer ); + QList myList; + myList << myLayer; + QgsMapLayerRegistry::instance()->addMapLayers( myList ); } else diff --git a/src/plugins/spatialquery/qgsspatialquerydialog.cpp b/src/plugins/spatialquery/qgsspatialquerydialog.cpp index a23f0a6a1d2..a3fd2d0d325 100644 --- a/src/plugins/spatialquery/qgsspatialquerydialog.cpp +++ b/src/plugins/spatialquery/qgsspatialquerydialog.cpp @@ -298,7 +298,8 @@ bool QgsSpatialQueryDialog::addLayerSubset( QString name, QString subset ) delete addLyr; return false; } - QgsMapLayerRegistry::instance()->addMapLayer( addLyr ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << addLyr ); return true; } // bool QgsSpatialQueryDialog::addLayerSubset( QString name, QString subset ) diff --git a/src/plugins/sqlanywhere/sqlanywhere.cpp b/src/plugins/sqlanywhere/sqlanywhere.cpp index ed5e8ab1e03..c5ff7596fc7 100644 --- a/src/plugins/sqlanywhere/sqlanywhere.cpp +++ b/src/plugins/sqlanywhere/sqlanywhere.cpp @@ -152,7 +152,9 @@ void SqlAnywhere::addSqlAnywhereLayer() SaDebugMsg( "Beautifying layer name. new: " + layer->name() ); // register this layer with the central layers registry - QgsMapLayerRegistry::instance()->addMapLayer(( QgsVectorLayer* )layer ); + QList myList; + myList << ( QgsVectorLayer* )layer; + QgsMapLayerRegistry::instance()->addMapLayers( myList ); } else { diff --git a/tests/src/core/regression992.cpp b/tests/src/core/regression992.cpp index b5690c215e3..97ee18964b1 100644 --- a/tests/src/core/regression992.cpp +++ b/tests/src/core/regression992.cpp @@ -75,7 +75,9 @@ void Regression992::initTestCase() mpRasterLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), myRasterFileInfo.completeBaseName() ); // Register the layer with the registry - QgsMapLayerRegistry::instance()->addMapLayer( mpRasterLayer ); + QList myList; + myList << mpRasterLayer; + QgsMapLayerRegistry::instance()->addMapLayers( myList ); // add the test layer to the maprender mpMapRenderer = new QgsMapRenderer(); QStringList myLayers; diff --git a/tests/src/core/testqgsmaprenderer.cpp b/tests/src/core/testqgsmaprenderer.cpp index 00eb01595cb..650c3ea0d1f 100644 --- a/tests/src/core/testqgsmaprenderer.cpp +++ b/tests/src/core/testqgsmaprenderer.cpp @@ -166,7 +166,8 @@ void TestQgsMapRenderer::initTestCase() mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry - QgsMapLayerRegistry::instance()->addMapLayer( mpPolysLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mpPolysLayer ); // add the test layer to the maprender mpMapRenderer = new QgsMapRenderer(); QStringList myLayers; diff --git a/tests/src/core/testqgsrasterlayer.cpp b/tests/src/core/testqgsrasterlayer.cpp index c9019ff93a2..1a82553665d 100644 --- a/tests/src/core/testqgsrasterlayer.cpp +++ b/tests/src/core/testqgsrasterlayer.cpp @@ -90,8 +90,10 @@ void TestQgsRasterLayer::initTestCase() mpLandsatRasterLayer = new QgsRasterLayer( myLandsatRasterFileInfo.filePath(), myLandsatRasterFileInfo.completeBaseName() ); // Register the layer with the registry - QgsMapLayerRegistry::instance()->addMapLayer( mpRasterLayer ); - QgsMapLayerRegistry::instance()->addMapLayer( mpLandsatRasterLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mpRasterLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mpLandsatRasterLayer ); // add the test layer to the maprender mpMapRenderer = new QgsMapRenderer(); QStringList myLayers; @@ -237,8 +239,10 @@ void TestQgsRasterLayer::registry() QgsRasterLayer * mypLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), myRasterFileInfo.completeBaseName() ); - QgsMapLayerRegistry::instance()->addMapLayer( mypLayer, false ); - QgsMapLayerRegistry::instance()->removeMapLayer( mypLayer->id() ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mypLayer, false ); + QgsMapLayerRegistry::instance()->removeMapLayers( + QStringList() << mypLayer->id() ); //cleanup //delete mypLayer; } diff --git a/tests/src/core/testqgsrenderers.cpp b/tests/src/core/testqgsrenderers.cpp index 88a843dde56..44fe6aaaa01 100644 --- a/tests/src/core/testqgsrenderers.cpp +++ b/tests/src/core/testqgsrenderers.cpp @@ -90,7 +90,8 @@ void TestQgsRenderers::initTestCase() mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry - QgsMapLayerRegistry::instance()->addMapLayer( mpPointsLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mpPointsLayer ); // //create a poly layer that will be used in all tests... @@ -100,7 +101,8 @@ void TestQgsRenderers::initTestCase() mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry - QgsMapLayerRegistry::instance()->addMapLayer( mpPolysLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mpPolysLayer ); // @@ -111,7 +113,8 @@ void TestQgsRenderers::initTestCase() mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), myLineFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry - QgsMapLayerRegistry::instance()->addMapLayer( mpLinesLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mpLinesLayer ); // // We only need maprender instead of mapcanvas // since maprender does not require a qui diff --git a/tests/src/core/testqgsvectorlayer.cpp b/tests/src/core/testqgsvectorlayer.cpp index 81cec16cfec..24371d6fff3 100644 --- a/tests/src/core/testqgsvectorlayer.cpp +++ b/tests/src/core/testqgsvectorlayer.cpp @@ -81,7 +81,8 @@ class TestQgsVectorLayer: public QObject mpNonSpatialLayer = new QgsVectorLayer( myDbfFileInfo.filePath(), myDbfFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry - QgsMapLayerRegistry::instance()->addMapLayer( mpNonSpatialLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mpNonSpatialLayer ); // //create a point layer that will be used in all tests... // @@ -90,7 +91,8 @@ class TestQgsVectorLayer: public QObject mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), myPointFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry - QgsMapLayerRegistry::instance()->addMapLayer( mpPointsLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mpPointsLayer ); // //create a poly layer that will be used in all tests... @@ -100,7 +102,8 @@ class TestQgsVectorLayer: public QObject mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(), myPolyFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry - QgsMapLayerRegistry::instance()->addMapLayer( mpPolysLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mpPolysLayer ); // @@ -111,7 +114,8 @@ class TestQgsVectorLayer: public QObject mpLinesLayer = new QgsVectorLayer( myLineFileInfo.filePath(), myLineFileInfo.completeBaseName(), "ogr" ); // Register the layer with the registry - QgsMapLayerRegistry::instance()->addMapLayer( mpLinesLayer ); + QgsMapLayerRegistry::instance()->addMapLayers( + QList() << mpLinesLayer ); // // We only need maprender instead of mapcanvas // since maprender does not require a qui