roam-qgis / Roam

Simple data collection built using QGIS.
http://roam-docs.readthedocs.org/en/latest/
GNU General Public License v2.0
169 stars 61 forks source link

module Roam:api:utils - layer_by_name bug - index out of bounds #421

Open PaulHagar opened 5 years ago

PaulHagar commented 5 years ago

Using the layer_by_name() function can cause an Index out of bounds error if the layers_by_name call returns no results. Suggest confirming length of result > 0 before trying to return result 0.

def layer_by_name(name): """ Return a layer from QGIS using its name. :param name: The name of the layer :return: A single layer with the given layer name """ return layers_by_name(name)[0]