Skip to content

Commit 7ffde33

Browse files
author
wonder
committed
Check whether layer index is valid in getZpos().
git-svn-id: http://svn.osgeo.org/qgis/trunk@6744 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1f88873 commit 7ffde33

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/gui/qgsmapcanvas.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,11 @@ QgsMapRender* QgsMapCanvas::mapRender()
175175

176176
QgsMapLayer* QgsMapCanvas::getZpos(int index)
177177
{
178-
QString layer = mMapRender->layerSet()[index];
179-
return QgsMapLayerRegistry::instance()->mapLayer(layer);
178+
std::deque<QString>& layers = mMapRender->layerSet();
179+
if (index >= 0 && index < (int) layers.size())
180+
return QgsMapLayerRegistry::instance()->mapLayer(layers[index]);
181+
else
182+
return NULL;
180183
}
181184

182185

0 commit comments

Comments
 (0)