Skip to content

Commit

Permalink
Fix for ticket #474. The behaviour when different layers are being re…
Browse files Browse the repository at this point in the history
…projected

into coordinate systems that are 'not right' will still be a bit confusing to
the novice user, but qgis won't crash when doing so now.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6345 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Dec 29, 2006
1 parent eb5389c commit 6e90804
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ void QgsLegend::zoomToLayerExtent()

QgsRect transformedExtent;
QgsRect layerExtent;
QgsRect r2;
QgsCoordinateTransform *ct;
QgsMapLayer* theLayer;
bool first(true);

Expand All @@ -1700,16 +1700,22 @@ void QgsLegend::zoomToLayerExtent()
{
layerExtent = theLayer->extent();

if (theLayer->projectionsEnabled())
if (theLayer->projectionsEnabled()
&& (ct = theLayer->coordinateTransform()))
{
try
{
layerExtent = ct->transformBoundingBox(layerExtent, QgsCoordinateTransform::FORWARD);
}
catch (QgsCsException &cse)
{
// Catch any exceptions, and by default the rest of the code
// just gets the unprojected extent instead.
}

// std::cerr<<__FILE__<<__LINE__<<' '
// << layerExtent.stringRep().toLocal8Bit().data() << '\n';

bool split = theLayer->projectExtent(layerExtent, r2);

// std::cerr<<__FILE__<<__LINE__<<' '
// << layerExtent.stringRep().toLocal8Bit().data() << '\n';
// If the extent is odd, default to the unprojected extent.
if (!layerExtent.isFinite())
layerExtent = theLayer->extent();
}

if (first)
Expand Down

0 comments on commit 6e90804

Please sign in to comment.