Skip to content

Commit

Permalink
Check whether layer index is valid in getZpos().
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@6744 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Mar 2, 2007
1 parent 1f88873 commit 7ffde33
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ QgsMapRender* QgsMapCanvas::mapRender()

QgsMapLayer* QgsMapCanvas::getZpos(int index)
{
QString layer = mMapRender->layerSet()[index];
return QgsMapLayerRegistry::instance()->mapLayer(layer);
std::deque<QString>& layers = mMapRender->layerSet();
if (index >= 0 && index < (int) layers.size())
return QgsMapLayerRegistry::instance()->mapLayer(layers[index]);
else
return NULL;
}


Expand Down

0 comments on commit 7ffde33

Please sign in to comment.