Skip to content
Permalink
Browse files

Fix project defaults to EPSG:4326 when a non-spatial layer is first

layer added

Fixes #19690
  • Loading branch information
nyalldawson committed Aug 25, 2018
1 parent 1b56055 commit d84252c97c83d059d8a2fdb725468328f08b136f
@@ -63,9 +63,15 @@ void QgsLayerTreeMapCanvasBridge::setCanvasLayers()
else
setCanvasLayers( mRoot, canvasLayers, overviewLayers, allLayerOrder );

QList<QgsLayerTreeLayer *> layerNodes = mRoot->findLayers();
int currentLayerCount = layerNodes.count();
bool firstLayers = mAutoSetupOnFirstLayer && mLastLayerCount == 0 && currentLayerCount != 0;
const QList<QgsLayerTreeLayer *> layerNodes = mRoot->findLayers();
int currentSpatialLayerCount = 0;
for ( QgsLayerTreeLayer *layerNode : layerNodes )
{
if ( layerNode->layer() && layerNode->layer()->isSpatial() )
currentSpatialLayerCount++;
}

bool firstLayers = mAutoSetupOnFirstLayer && mLastLayerCount == 0 && currentSpatialLayerCount != 0;

mCanvas->setLayers( canvasLayers );
if ( mOverviewCanvas )
@@ -95,8 +101,8 @@ void QgsLayerTreeMapCanvasBridge::setCanvasLayers()
QgsProject::instance()->setCrs( mFirstCRS );
}

mLastLayerCount = currentLayerCount;
if ( currentLayerCount == 0 )
mLastLayerCount = currentSpatialLayerCount;
if ( currentSpatialLayerCount == 0 )
mFirstCRS = QgsCoordinateReferenceSystem();

mPendingCanvasUpdate = false;
Binary file not shown.

0 comments on commit d84252c

Please sign in to comment.
You can’t perform that action at this time.