Skip to content

Commit

Permalink
Fix datum transform prompt is not always showing after adding new layers
Browse files Browse the repository at this point in the history
to a project

Fixes #29306
  • Loading branch information
nyalldawson committed Jun 11, 2019
1 parent b34539a commit d2961af
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4725,6 +4725,8 @@ bool QgisApp::addVectorLayersPrivate( const QStringList &layerQStringList, const
// the list if he wants to load it.
delete layer;

for ( QgsMapLayer *l : addedLayers )
askUserForDatumTransform( l->crs(), QgsProject::instance()->crs() );
}
else if ( !sublayers.isEmpty() ) // there is 1 layer of data available
{
Expand Down Expand Up @@ -4777,6 +4779,7 @@ bool QgisApp::addVectorLayersPrivate( const QStringList &layerQStringList, const
bool ok;
l->loadDefaultStyle( ok );
l->loadDefaultMetadata( ok );
askUserForDatumTransform( l->crs(), QgsProject::instance()->crs() );
}
activateDeactivateLayerRelatedActions( activeLayer() );

Expand Down Expand Up @@ -4831,6 +4834,9 @@ QgsMeshLayer *QgisApp::addMeshLayerPrivate( const QString &url, const QString &b
freezeCanvases();

QgsProject::instance()->addMapLayer( layer.get() );

askUserForDatumTransform( layer->crs(), QgsProject::instance()->crs() );

bool ok;
layer->loadDefaultStyle( ok );
layer->loadDefaultMetadata( ok );
Expand Down Expand Up @@ -11152,6 +11158,8 @@ QgsVectorLayer *QgisApp::addVectorLayerPrivate( const QString &vectorLayerPath,
// the list if he wants to load it.
delete layer;
layer = addedLayers.isEmpty() ? nullptr : qobject_cast< QgsVectorLayer * >( addedLayers.at( 0 ) );
for ( QgsMapLayer *l : addedLayers )
askUserForDatumTransform( l->crs(), QgsProject::instance()->crs() );
}
else
{
Expand All @@ -11168,6 +11176,9 @@ QgsVectorLayer *QgisApp::addVectorLayerPrivate( const QString &vectorLayerPath,

myList << layer;
QgsProject::instance()->addMapLayers( myList );

askUserForDatumTransform( layer->crs(), QgsProject::instance()->crs() );

bool ok;
layer->loadDefaultStyle( ok );
layer->loadDefaultMetadata( ok );
Expand Down Expand Up @@ -11206,17 +11217,14 @@ void QgisApp::addMapLayer( QgsMapLayer *mapLayer )
{
freezeCanvases();

// Let render() do its own cursor management
// QApplication::setOverrideCursor(Qt::WaitCursor);

if ( mapLayer->isValid() )
{
// Register this layer with the layers registry
QList<QgsMapLayer *> myList;
myList << mapLayer;
QgsProject::instance()->addMapLayers( myList );
// add it to the mapcanvas collection
// not necessary since adding to registry adds to canvas mMapCanvas->addLayer(theMapLayer);

askUserForDatumTransform( mapLayer->crs(), QgsProject::instance()->crs() );
}
else
{
Expand All @@ -11227,10 +11235,6 @@ void QgisApp::addMapLayer( QgsMapLayer *mapLayer )
// draw the map
freezeCanvases( false );
refreshMapCanvas();

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

}

void QgisApp::embedLayers()
Expand Down Expand Up @@ -13239,6 +13243,8 @@ bool QgisApp::addRasterLayer( QgsRasterLayer *rasterLayer )
myList << rasterLayer;
QgsProject::instance()->addMapLayers( myList );

askUserForDatumTransform( rasterLayer->crs(), QgsProject::instance()->crs() );

return true;
}

Expand Down Expand Up @@ -13297,6 +13303,8 @@ QgsRasterLayer *QgisApp::addRasterLayerPrivate(
// The first layer loaded is not useful in that case. The user can select it in
// the list if he wants to load it.
delete layer;
for ( QgsMapLayer *l : qgis::as_const( subLayers ) )
askUserForDatumTransform( l->crs(), QgsProject::instance()->crs() );
layer = !subLayers.isEmpty() ? qobject_cast< QgsRasterLayer * >( subLayers.at( 0 ) ) : nullptr;
}
}
Expand Down

0 comments on commit d2961af

Please sign in to comment.