Skip to content

Commit e930bee

Browse files
elpasonyalldawson
authored andcommittedApr 17, 2019
Add mandatory options to QgsVectorLayer ctor
... and deprecate the rest. In QGIS 4 we'll have to get rid of the deprecated default ctor and create a new one which takes no arguments.
1 parent 6813a55 commit e930bee

40 files changed

+134
-70
lines changed
 

‎python/core/auto_generated/qgsvectorlayer.sip.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ Constructor for LayerOptions.
352352

353353
};
354354

355+
355356
explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
356357
const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() ) /Deprecated/;
357358
%Docstring

‎python/core/auto_generated/raster/qgsrasterlayer.sip.in

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,21 @@ Constructor. Provider is not set.
104104
struct LayerOptions
105105
{
106106

107-
explicit LayerOptions( bool loadDefaultStyle = true,
108-
const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext() );
107+
explicit LayerOptions( bool loadDefaultStyle = true ) /Deprecated/;
109108
%Docstring
110109
Constructor for LayerOptions.
110+
111+
.. deprecated:: Use version with transformContext argument instead
112+
%End
113+
114+
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext, bool loadDefaultStyle = true );
115+
%Docstring
116+
Constructor for LayerOptions.
117+
118+
.. versionadded:: 3.10
111119
%End
112120

121+
113122
bool loadDefaultStyle;
114123

115124
QgsCoordinateTransformContext transformContext;

‎src/app/browser/qgsinbuiltdataitemproviders.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men
363363
{
364364
case QgsMapLayerType::VectorLayer:
365365
{
366-
std::unique_ptr<QgsVectorLayer> layer( new QgsVectorLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey() ) );
366+
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
367+
std::unique_ptr<QgsVectorLayer> layer( new QgsVectorLayer( options, layerItem->uri(), layerItem->name(), layerItem->providerKey() ) );
367368
if ( layer && layer->isValid() )
368369
{
369370
QgisApp::instance()->saveAsFile( layer.get(), false, false );

‎src/app/dwg/qgsdwgimportdialog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ void QgsDwgImportDialog::pbLoadDatabase_clicked()
148148

149149
bool lblVisible = false;
150150

151-
QgsVectorLayer::LayerOptions options;
151+
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
152152
options.loadDefaultStyle = false;
153-
std::unique_ptr<QgsVectorLayer> d( new QgsVectorLayer( QStringLiteral( "%1|layername=drawing" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), options ) );
153+
std::unique_ptr<QgsVectorLayer> d( new QgsVectorLayer( options, QStringLiteral( "%1|layername=drawing" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ) ) );
154154
if ( d && d->isValid() )
155155
{
156156
int idxPath = d->fields().lookupField( QStringLiteral( "path" ) );
@@ -185,7 +185,7 @@ void QgsDwgImportDialog::pbLoadDatabase_clicked()
185185

186186
lblMessage->setVisible( lblVisible );
187187

188-
std::unique_ptr<QgsVectorLayer> l( new QgsVectorLayer( QStringLiteral( "%1|layername=layers" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), options ) );
188+
std::unique_ptr<QgsVectorLayer> l( new QgsVectorLayer( options, QStringLiteral( "%1|layername=layers" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ) ) );
189189
if ( l && l->isValid() )
190190
{
191191
int idxName = l->fields().lookupField( QStringLiteral( "name" ) );
@@ -263,9 +263,9 @@ void QgsDwgImportDialog::pbImportDrawing_clicked()
263263

264264
QgsVectorLayer *QgsDwgImportDialog::layer( QgsLayerTreeGroup *layerGroup, const QString &layerFilter, const QString &table )
265265
{
266-
QgsVectorLayer::LayerOptions options;
266+
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
267267
options.loadDefaultStyle = false;
268-
QgsVectorLayer *l = new QgsVectorLayer( QStringLiteral( "%1|layername=%2" ).arg( mDatabaseFileWidget->filePath(), table ), table, QStringLiteral( "ogr" ), options );
268+
QgsVectorLayer *l = new QgsVectorLayer( options, QStringLiteral( "%1|layername=%2" ).arg( mDatabaseFileWidget->filePath(), table ), table, QStringLiteral( "ogr" ) );
269269
l->setSubsetString( QStringLiteral( "%1space=0 AND block=-1" ).arg( layerFilter ) );
270270

271271
if ( l->featureCount() == 0 )

‎src/app/qgisapp.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4638,7 +4638,7 @@ static void setupVectorLayer( const QString &vectorLayerPath,
46384638
QString composedURI( uriParts.value( QStringLiteral( "path" ) ).toString() );
46394639
composedURI += "|layername=" + rawLayerName;
46404640

4641-
auto newLayer = qgis::make_unique<QgsVectorLayer>( composedURI, layer->name(), QStringLiteral( "ogr" ), options );
4641+
auto newLayer = qgis::make_unique<QgsVectorLayer>( options, composedURI, layer->name(), QStringLiteral( "ogr" ) );
46424642
if ( newLayer && newLayer->isValid() )
46434643
{
46444644
delete layer;
@@ -4716,7 +4716,7 @@ bool QgisApp::addVectorLayersPrivate( const QStringList &layerQStringList, const
47164716
QApplication::setOverrideCursor( Qt::WaitCursor );
47174717
qApp->processEvents();
47184718
}
4719-
QgsVectorLayer *layer = new QgsVectorLayer( src, baseName, QStringLiteral( "ogr" ), options );
4719+
QgsVectorLayer *layer = new QgsVectorLayer( options, src, baseName, QStringLiteral( "ogr" ) );
47204720
Q_CHECK_PTR( layer );
47214721
if ( isVsiCurl || isRemoteUrl )
47224722
{
@@ -5256,7 +5256,7 @@ QList<QgsMapLayer *> QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
52565256
QString name = fileName + " " + def.layerName;
52575257
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
52585258
options.loadDefaultStyle = false;
5259-
QgsVectorLayer *layer = new QgsVectorLayer( composedURI, name, QStringLiteral( "ogr" ), options );
5259+
QgsVectorLayer *layer = new QgsVectorLayer( options, composedURI, name, QStringLiteral( "ogr" ) );
52605260
if ( layer && layer->isValid() )
52615261
{
52625262
result << layer;
@@ -5320,7 +5320,7 @@ void QgisApp::addDatabaseLayers( QStringList const &layerPathList, QString const
53205320

53215321
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
53225322
options.loadDefaultStyle = false;
5323-
QgsVectorLayer *layer = new QgsVectorLayer( uri.uri( false ), uri.table(), providerKey, options );
5323+
QgsVectorLayer *layer = new QgsVectorLayer( options, uri.uri( false ), uri.table(), providerKey );
53245324
Q_CHECK_PTR( layer );
53255325

53265326
if ( ! layer )
@@ -5397,7 +5397,8 @@ void QgisApp::replaceSelectedVectorLayer( const QString &oldId, const QString &u
53975397
if ( !old )
53985398
return;
53995399
QgsVectorLayer *oldLayer = static_cast<QgsVectorLayer *>( old );
5400-
QgsVectorLayer *newLayer = new QgsVectorLayer( uri, layerName, provider );
5400+
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
5401+
QgsVectorLayer *newLayer = new QgsVectorLayer( options, uri, layerName, provider );
54015402
if ( !newLayer || !newLayer->isValid() )
54025403
return;
54035404

@@ -9853,7 +9854,8 @@ void QgisApp::layerSubsetString()
98539854
QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes )
98549855
{
98559856
QgsVirtualLayerDefinition def = QgsVirtualLayerDefinitionUtils::fromJoinedLayer( vlayer );
9856-
QgsVectorLayer *newLayer = new QgsVectorLayer( def.toString(), vlayer->name() + " (virtual)", QStringLiteral( "virtual" ) );
9857+
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
9858+
QgsVectorLayer *newLayer = new QgsVectorLayer( options, def.toString(), vlayer->name() + " (virtual)", QStringLiteral( "virtual" ) );
98579859
if ( newLayer->isValid() )
98589860
{
98599861
duplicateVectorStyle( vlayer, newLayer );
@@ -11111,7 +11113,7 @@ QgsVectorLayer *QgisApp::addVectorLayerPrivate( const QString &vectorLayerPath,
1111111113
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
1111211114
// Default style is loaded later in this method
1111311115
options.loadDefaultStyle = false;
11114-
QgsVectorLayer *layer = new QgsVectorLayer( vectorLayerPath, baseName, providerKey, options );
11116+
QgsVectorLayer *layer = new QgsVectorLayer( options, vectorLayerPath, baseName, providerKey );
1111511117

1111611118
if ( authok && layer && layer->isValid() )
1111711119
{

‎src/app/qgsappscreenshots.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
4242
: mSaveDirectory( saveDirectory )
4343
{
4444
QString layerDef = QStringLiteral( "Point?crs=epsg:4326&field=pk:integer&field=my_text:string&field=fk_polygon:integer&field=my_double:double&key=pk" );
45-
mLineLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Line Layer" ), QStringLiteral( "memory" ) );
45+
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
46+
mLineLayer = new QgsVectorLayer( options, layerDef, QStringLiteral( "Line Layer" ), QStringLiteral( "memory" ) );
4647
layerDef = QStringLiteral( "Polygon?crs=epsg:2056&field=pk:integer&field=my_text:string&field=my_integer:integer&field=height:double&key=pk" );
47-
mPolygonLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Polygon Layer" ), QStringLiteral( "memory" ) );
48+
mPolygonLayer = new QgsVectorLayer( options, layerDef, QStringLiteral( "Polygon Layer" ), QStringLiteral( "memory" ) );
4849

4950
QString dataPath( TEST_DATA_DIR ); //defined in CmakeLists.txt
5051
mRasterLayer = new QgsRasterLayer( dataPath + "/raster/with_color_table.tif", QStringLiteral( "raster" ), QStringLiteral( "gdal" ) );

‎src/app/qgsnewspatialitelayerdialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ bool QgsNewSpatialiteLayerDialog::apply()
454454
}
455455
}
456456

457-
QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "dbname='%1' table='%2'%3 sql=" )
457+
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
458+
QgsVectorLayer *layer = new QgsVectorLayer( options, QStringLiteral( "dbname='%1' table='%2'%3 sql=" )
458459
.arg( mDatabaseComboBox->currentText(),
459460
leLayerName->text(),
460461
mGeometryTypeBox->currentIndex() != 0 ? QStringLiteral( "(%1)" ).arg( leGeometryColumn->text() ) : QString() ),

‎src/app/qgsstatusbarcoordinateswidget.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ void QgsStatusBarCoordinatesWidget::contributors()
212212
}
213213
QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/contributors.json" );
214214
QFileInfo fileInfo = QFileInfo( fileName );
215-
QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(),
215+
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
216+
QgsVectorLayer *layer = new QgsVectorLayer( options, fileInfo.absoluteFilePath(),
216217
tr( "QGIS Contributors" ), QStringLiteral( "ogr" ) );
217218
// Register this layer with the layers registry
218219
QgsProject::instance()->addMapLayer( layer );
@@ -228,7 +229,8 @@ void QgsStatusBarCoordinatesWidget::world()
228229
}
229230
QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/world_map.shp" );
230231
QFileInfo fileInfo = QFileInfo( fileName );
231-
QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(),
232+
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
233+
QgsVectorLayer *layer = new QgsVectorLayer( options, fileInfo.absoluteFilePath(),
232234
tr( "World Map" ), QStringLiteral( "ogr" ) );
233235
// Register this layer with the layers registry
234236
QgsProject::instance()->addMapLayer( layer );
@@ -242,7 +244,8 @@ void QgsStatusBarCoordinatesWidget::hackfests()
242244
}
243245
QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/qgis-hackfests.json" );
244246
QFileInfo fileInfo = QFileInfo( fileName );
245-
QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(),
247+
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
248+
QgsVectorLayer *layer = new QgsVectorLayer( options, fileInfo.absoluteFilePath(),
246249
tr( "QGIS Hackfests" ), QStringLiteral( "ogr" ) );
247250
// Register this layer with the layers registry
248251
QgsProject::instance()->addMapLayer( layer );

‎src/core/layout/qgslayoutitemmapoverview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
QgsLayoutItemMapOverview::QgsLayoutItemMapOverview( const QString &name, QgsLayoutItemMap *map )
3535
: QgsLayoutItemMapItem( name, map )
36-
, mExtentLayer( qgis::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=EPSG:4326" ), QStringLiteral( "overview" ), QStringLiteral( "memory" ) ) )
36+
, mExtentLayer( qgis::make_unique< QgsVectorLayer >( QgsVectorLayer::LayerOptions( QgsCoordinateTransformContext() ), QStringLiteral( "Polygon?crs=EPSG:4326" ), QStringLiteral( "overview" ), QStringLiteral( "memory" ) ) )
3737
{
3838
createDefaultFrameSymbol();
3939
}

‎src/core/processing/qgsprocessingutils.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class ProjectionSettingRestorer
214214
};
215215
///@endcond PRIVATE
216216

217-
QgsMapLayer *QgsProcessingUtils::loadMapLayerFromString( const QString &string, LayerHint typeHint )
217+
QgsMapLayer *QgsProcessingUtils::loadMapLayerFromString( const QString &string, const QgsCoordinateTransformContext &transformContext, LayerHint typeHint )
218218
{
219219
QStringList components = string.split( '|' );
220220
if ( components.isEmpty() )
@@ -237,9 +237,9 @@ QgsMapLayer *QgsProcessingUtils::loadMapLayerFromString( const QString &string,
237237
// brute force attempt to load a matching layer
238238
if ( typeHint == LayerHint::UnknownType || typeHint == LayerHint::Vector )
239239
{
240-
QgsVectorLayer::LayerOptions options;
240+
QgsVectorLayer::LayerOptions options { transformContext };
241241
options.loadDefaultStyle = false;
242-
std::unique_ptr< QgsVectorLayer > layer( new QgsVectorLayer( string, name, QStringLiteral( "ogr" ), options ) );
242+
std::unique_ptr< QgsVectorLayer > layer = qgis::make_unique<QgsVectorLayer>( options, string, name, QStringLiteral( "ogr" ) );
243243
if ( layer->isValid() )
244244
{
245245
return layer.release();
@@ -288,7 +288,7 @@ QgsMapLayer *QgsProcessingUtils::mapLayerFromString( const QString &string, QgsP
288288
if ( !allowLoadingNewLayers )
289289
return nullptr;
290290

291-
layer = loadMapLayerFromString( string, typeHint );
291+
layer = loadMapLayerFromString( string, context.transformContext(), typeHint );
292292
if ( layer )
293293
{
294294
context.temporaryLayerStore()->addMapLayer( layer );
@@ -601,7 +601,8 @@ QgsFeatureSink *QgsProcessingUtils::createFeatureSink( QString &destination, Qgs
601601
else
602602
{
603603
//create empty layer
604-
std::unique_ptr< QgsVectorLayerExporter > exporter( new QgsVectorLayerExporter( uri, providerKey, newFields, geometryType, crs, true, options, sinkFlags ) );
604+
const QgsVectorLayer::LayerOptions layerOptions { context.transformContext() };
605+
std::unique_ptr< QgsVectorLayerExporter > exporter = qgis::make_unique<QgsVectorLayerExporter>( uri, providerKey, newFields, geometryType, crs, true, options, sinkFlags );
605606
if ( exporter->errorCode() )
606607
{
607608
throw QgsProcessingException( QObject::tr( "Could not create layer %1: %2" ).arg( destination, exporter->errorMessage() ) );
@@ -610,15 +611,14 @@ QgsFeatureSink *QgsProcessingUtils::createFeatureSink( QString &destination, Qgs
610611
// use destination string as layer name (eg "postgis:..." )
611612
if ( !layerName.isEmpty() )
612613
uri += QStringLiteral( "|layername=%1" ).arg( layerName );
613-
std::unique_ptr< QgsVectorLayer > layer( new QgsVectorLayer( uri, destination, providerKey ) );
614+
std::unique_ptr< QgsVectorLayer > layer = qgis::make_unique<QgsVectorLayer>( layerOptions, uri, destination, providerKey );
614615
// update destination to layer ID
615616
destination = layer->id();
616617

617618
context.temporaryLayerStore()->addMapLayer( layer.release() );
618619
return new QgsProcessingFeatureSink( exporter.release(), destination, context, true );
619620
}
620621
}
621-
return nullptr;
622622
}
623623

624624
void QgsProcessingUtils::createFeatureSinkPython( QgsFeatureSink **sink, QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &options )

‎src/core/processing/qgsprocessingutils.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,27 @@ class CORE_EXPORT QgsProcessingUtils
310310
*/
311311
static QgsMapLayer *mapLayerFromStore( const QString &string, QgsMapLayerStore *store, QgsProcessingUtils::LayerHint typeHint = QgsProcessingUtils::LayerHint::UnknownType );
312312

313+
/**
314+
* Interprets a string as a map layer. The method will attempt to
315+
* load a layer matching the passed \a string using the given coordinate
316+
* \a transformContext.
317+
* E.g. if the string is a file path,
318+
* then the layer at this file path will be loaded.
319+
* The caller takes responsibility for deleting the returned map layer.
320+
*
321+
* \since QGIS 3.8
322+
*/
323+
static QgsMapLayer *loadMapLayerFromString( const QString &string, const QgsCoordinateTransformContext &transformContext, LayerHint typeHint = UnknownType );
324+
313325
/**
314326
* Interprets a string as a map layer. The method will attempt to
315327
* load a layer matching the passed \a string. E.g. if the string is a file path,
316328
* then the layer at this file path will be loaded.
317329
* The caller takes responsibility for deleting the returned map layer.
330+
*
331+
* \deprecated use mapLayerFromString() that takes QgsCoordinateTransformContext as an argument instead
318332
*/
319-
static QgsMapLayer *loadMapLayerFromString( const QString &string, QgsProcessingUtils::LayerHint typeHint = QgsProcessingUtils::LayerHint::UnknownType );
333+
Q_DECL_DEPRECATED static QgsMapLayer *loadMapLayerFromString( const QString &string, LayerHint typeHint = UnknownType ) SIP_DEPRECATED ;
320334

321335
static void parseDestinationString( QString &destination, QString &providerKey, QString &uri, QString &layerName, QString &format, QMap<QString, QVariant> &options, bool &useWriter, QString &extension );
322336

‎src/core/providers/memory/qgsmemoryproviderutils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,5 @@ QgsVectorLayer *QgsMemoryProviderUtils::createMemoryLayer( const QString &name,
7474
}
7575

7676
QString uri = geomType + '?' + parts.join( '&' );
77-
78-
return new QgsVectorLayer( uri, name, QStringLiteral( "memory" ) );
77+
return new QgsVectorLayer( QgsVectorLayer::LayerOptions( QgsCoordinateTransformContext() ), uri, name, QStringLiteral( "memory" ) );
7978
}

‎src/core/qgsauxiliarystorage.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ const QVector<QgsPalLayerSettings::Property> palHiddenProperties
6161
//
6262

6363
QgsAuxiliaryLayer::QgsAuxiliaryLayer( const QString &pkField, const QString &filename, const QString &table, QgsVectorLayer *vlayer )
64-
: QgsVectorLayer( QString( "%1|layername=%2" ).arg( filename, table ), QString( "%1_auxiliarystorage" ).arg( table ), "ogr" )
64+
: QgsVectorLayer( QgsVectorLayer::LayerOptions( QgsCoordinateTransformContext( ) ),
65+
QString( "%1|layername=%2" ).arg( filename, table ),
66+
QString( "%1_auxiliarystorage" ).arg( table ), "ogr" )
6567
, mFileName( filename )
6668
, mTable( table )
6769
, mLayer( vlayer )

‎src/core/qgslayerdefinition.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ QList<QgsMapLayer *> QgsLayerDefinition::loadLayerDefinitionLayers( QDomDocument
265265

266266
if ( type == QLatin1String( "vector" ) )
267267
{
268-
layer = new QgsVectorLayer;
268+
const QgsVectorLayer::LayerOptions options { QgsCoordinateTransformContext() };
269+
layer = new QgsVectorLayer( options );
269270
}
270271
else if ( type == QLatin1String( "raster" ) )
271272
{

‎src/core/qgsmimedatautils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ QgsVectorLayer *QgsMimeDataUtils::Uri::vectorLayer( bool &owner, QString &error
9494
return vectorLayer;
9595
}
9696
owner = true;
97-
return new QgsVectorLayer( uri, name, providerKey );
97+
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
98+
return new QgsVectorLayer( options, uri, name, providerKey );
9899
}
99100

100101
QgsRasterLayer *QgsMimeDataUtils::Uri::rasterLayer( bool &owner, QString &error ) const

0 commit comments

Comments
 (0)