Skip to content

Commit 6e90804

Browse files
author
g_j_m
committed
Fix for ticket #474. The behaviour when different layers are being reprojected
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
1 parent eb5389c commit 6e90804

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/legend/qgslegend.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ void QgsLegend::zoomToLayerExtent()
16891689

16901690
QgsRect transformedExtent;
16911691
QgsRect layerExtent;
1692-
QgsRect r2;
1692+
QgsCoordinateTransform *ct;
16931693
QgsMapLayer* theLayer;
16941694
bool first(true);
16951695

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

1703-
if (theLayer->projectionsEnabled())
1703+
if (theLayer->projectionsEnabled()
1704+
&& (ct = theLayer->coordinateTransform()))
17041705
{
1706+
try
1707+
{
1708+
layerExtent = ct->transformBoundingBox(layerExtent, QgsCoordinateTransform::FORWARD);
1709+
}
1710+
catch (QgsCsException &cse)
1711+
{
1712+
// Catch any exceptions, and by default the rest of the code
1713+
// just gets the unprojected extent instead.
1714+
}
17051715

1706-
// std::cerr<<__FILE__<<__LINE__<<' '
1707-
// << layerExtent.stringRep().toLocal8Bit().data() << '\n';
1708-
1709-
bool split = theLayer->projectExtent(layerExtent, r2);
1710-
1711-
// std::cerr<<__FILE__<<__LINE__<<' '
1712-
// << layerExtent.stringRep().toLocal8Bit().data() << '\n';
1716+
// If the extent is odd, default to the unprojected extent.
1717+
if (!layerExtent.isFinite())
1718+
layerExtent = theLayer->extent();
17131719
}
17141720

17151721
if (first)

0 commit comments

Comments
 (0)