Skip to content
Permalink
Browse files

Disallow changing of map layer registry directly

QgsMapLayerRegistry::mapLayers() returned reference is now const
  • Loading branch information
m-kuhn committed May 17, 2013
1 parent 91f3cea commit 35de29df9bea0a8d36d54aec677df054d7cd37ba
@@ -26,7 +26,7 @@ class QgsMapLayerRegistry : QObject
QList<QgsMapLayer *> mapLayersByName( QString layerName );

//! Retrieve the mapLayers collection (mainly intended for use by projection)
QMap<QString, QgsMapLayer*> & mapLayers();
const QMap<QString, QgsMapLayer*> & mapLayers();

/**
* @brief
@@ -28,7 +28,7 @@ QgsAtlasCompositionWidget::QgsAtlasCompositionWidget( QWidget* parent, QgsCompos

// populate the layer list
mAtlasCoverageLayerComboBox->clear();
QMap< QString, QgsMapLayer * >& layers = QgsMapLayerRegistry::instance()->mapLayers();
const QMap< QString, QgsMapLayer * >& layers = QgsMapLayerRegistry::instance()->mapLayers();
int idx = 0;
for ( QMap<QString, QgsMapLayer*>::const_iterator it = layers.begin(); it != layers.end(); ++it )
{
@@ -104,7 +104,7 @@ QVector<QgsRasterCalculatorEntry> QgsRasterCalcDialog::rasterEntries() const

void QgsRasterCalcDialog::insertAvailableRasterBands()
{
QMap<QString, QgsMapLayer*>& layers = QgsMapLayerRegistry::instance()->mapLayers();
const QMap<QString, QgsMapLayer*>& layers = QgsMapLayerRegistry::instance()->mapLayers();
QMap<QString, QgsMapLayer*>::const_iterator layerIt = layers.constBegin();

bool firstLayer = true;
@@ -169,7 +169,7 @@ void QgsMapLayerRegistry::reloadAllLayers()
}
}

QMap<QString, QgsMapLayer*> & QgsMapLayerRegistry::mapLayers()
const QMap<QString, QgsMapLayer*>& QgsMapLayerRegistry::mapLayers()
{
return mMapLayers;
}
@@ -49,7 +49,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
QList<QgsMapLayer *> mapLayersByName( QString layerName );

//! Retrieve the mapLayers collection (mainly intended for use by projection)
QMap<QString, QgsMapLayer*> & mapLayers();
const QMap<QString, QgsMapLayer*> & mapLayers();

/**
* @brief
@@ -985,14 +985,14 @@ bool QgsProject::write()
emit writeProject( *doc );

// within top level node save list of layers
QMap<QString, QgsMapLayer*> & layers = QgsMapLayerRegistry::instance()->mapLayers();
const QMap<QString, QgsMapLayer*> & layers = QgsMapLayerRegistry::instance()->mapLayers();

// Iterate over layers in zOrder
// Call writeXML() on each
QDomElement projectLayersNode = doc->createElement( "projectlayers" );
projectLayersNode.setAttribute( "layercount", qulonglong( layers.size() ) );

QMap<QString, QgsMapLayer*>::iterator li = layers.begin();
QMap<QString, QgsMapLayer*>::ConstIterator li = layers.constBegin();
while ( li != layers.end() )
{
//QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer(*li);

0 comments on commit 35de29d

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