mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Fix project defaults to EPSG:4326 when a non-spatial layer is first
layer added Fixes #19690
This commit is contained in:
parent
1b560559e5
commit
d84252c97c
@ -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;
|
||||
|
BIN
tests/testdata/polys_overlapping_with_id.dbf
vendored
BIN
tests/testdata/polys_overlapping_with_id.dbf
vendored
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user