Skip to content

Commit 1a08f0a

Browse files
committed
Add full test suite for QgsMapLayerRegistry, also don't emit
any layer removed signals when no layers will actually be removed
1 parent 6b3cb24 commit 1a08f0a

File tree

4 files changed

+452
-5
lines changed

4 files changed

+452
-5
lines changed

python/core/qgsmaplayerregistry.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class QgsMapLayerRegistry : QObject
3535
*/
3636
QList<QgsMapLayer *> mapLayersByName( const QString& layerName ) const;
3737

38-
/** Returns a list of all registered layers.
38+
/** Returns a map of all registered layers by layer ID.
3939
* @see mapLayer()
4040
* @see mapLayersByName()
4141
* @see layers()

src/core/qgsmaplayerregistry.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ void QgsMapLayerRegistry::removeMapLayers( const QList<QgsMapLayer*>& layers )
130130
layerIds << layer->id();
131131
}
132132

133+
if ( layerIds.isEmpty() )
134+
return;
135+
133136
emit layersWillBeRemoved( layerIds );
134137
emit layersWillBeRemoved( layers );
135138

src/core/qgsmaplayerregistry.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
6262
*/
6363
QList<QgsMapLayer *> mapLayersByName( const QString& layerName ) const;
6464

65-
/** Returns a list of all registered layers.
65+
/** Returns a map of all registered layers by layer ID.
6666
* @see mapLayer()
6767
* @see mapLayersByName()
6868
* @see layers()
6969
*/
7070
QMap<QString, QgsMapLayer*> mapLayers() const;
7171

72-
/** Rerturns a list of registered map layers with a specified layer type.
72+
/** Returns a list of registered map layers with a specified layer type.
7373
*
7474
* Example:
7575
*
@@ -183,6 +183,7 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
183183
* @see removeMapLayer()
184184
* @see removeAllMapLayers()
185185
*/
186+
//TODO QGIS 3.0 - add PyName alias to avoid list type conversion error
186187
void removeMapLayers( const QList<QgsMapLayer*>& layers );
187188

188189
/**

0 commit comments

Comments
 (0)