[Qgis-developer] Suppress emitting of signal: Bad practice?

Matthias Kuhn matthias.kuhn at gmx.ch
Fri Apr 19 07:07:40 PDT 2013


The QgsMapLayerRegistry::removeMapLayers allows to specify a parameter,
which will suppress emitting signals (altough it seems that this is not
even properly working [1]).

This parameter can lead to strange behavior, where some parts of the
software might not realize, that a layer has been removed and keep
references to no longer available objects.

The same fact applied to selected features in a vector layer. The
problem there was most probably, that only a method was available to
change the selection of a single feature and while iterating over
features, the signal was suppressed to not update the map canvas in
every iteration.

In my opinion, this is bad practice and we should remove these
parameters and add methods which allow batch jobs (removeMapLayers is
already in place) and then emit a single signal for a batch and call
this method wherever an iteration takes place.

So my questions are:
* Does somebody know why removeMapLayer(s) accepts this parameter?
* Do you see any negative effect of removing these or any upside in
keeping these?

API freeze is approaching fast and I think we should get rid of these
parameters now.

Any opinions on this?

Matthias

[1] http://hub.qgis.org/issues/7633 <http://hub.qgis.org/issues/7633>


More information about the Qgis-developer mailing list