Skip to content

Commit 75a5d5d

Browse files
committed
Remove unused skipAttributeCreation option in QgsVectorLayerExporter::exportLayer
1 parent 64b612f commit 75a5d5d

9 files changed

+8
-20
lines changed

doc/api_break.dox

+1
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,7 @@ QgsCoordinateReferenceSystem is now implicitly shared, using references to QgsCo
21892189
pointers makes for more robust, safer code. Use an invalid (default constructed) QgsCoordinateReferenceSystem
21902190
in code which previously passed a null pointer to QgsVectorLayerImport.
21912191
- importLayer was renamed to exportLayer
2192+
- The unused skipAttributeCreation in exportLayer() was removed
21922193
- The unused QProgressBar argument in the QgsVectorLayerImport was removed
21932194
- ImportError was renamed to ExportError
21942195
- The unused enum value ErrDriverNotFound was removed

python/core/qgsvectorlayerexporter.sip

-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class QgsVectorLayerExporter : QgsFeatureSink
5252
const QgsCoordinateReferenceSystem &destCRS,
5353
bool onlySelected = false,
5454
QString *errorMessage /Out/ = 0,
55-
bool skipAttributeCreation = false,
5655
QMap<QString, QVariant> *options = 0,
5756
QProgressDialog *progress = 0
5857
);
@@ -65,7 +64,6 @@ class QgsVectorLayerExporter : QgsFeatureSink
6564
not available
6665
\param onlySelected set to true to export only selected features
6766
\param errorMessage if non-null, will be set to any error messages
68-
\param skipAttributeCreation set to true to skip exporting feature attributes
6967
\param options optional provider dataset options
7068
\param progress optional progress dialog to show progress of export
7169
:return: NoError for a successful export, or encountered error

python/plugins/db_manager/dlg_export_vector.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def accept(self):
179179
self.inLayer.setCrs(inCrs)
180180

181181
# do the export!
182-
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, False,
182+
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs,
183183
False, options)
184184
except Exception as e:
185185
ret = -1

python/plugins/db_manager/dlg_import_vector.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def accept(self):
360360
onlySelected = self.chkSelectedFeatures.isChecked()
361361

362362
# do the import!
363-
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, onlySelected, False, options)
363+
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, onlySelected, options)
364364
except Exception as e:
365365
ret = -1
366366
errMsg = str(e)

python/plugins/processing/algs/qgis/ImportIntoPostGIS.py

-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ def processAlgorithm(self, context, feedback):
170170
providerName,
171171
self.crs,
172172
False,
173-
False,
174173
options,
175174
)
176175
if ret != 0:

python/plugins/processing/algs/qgis/ImportIntoSpatialite.py

-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ def processAlgorithm(self, context, feedback):
140140
providerName,
141141
self.crs,
142142
False,
143-
False,
144143
options,
145144
)
146145
if ret != 0:

src/core/qgsvectorlayerexporter.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
231231
const QgsCoordinateReferenceSystem &destCRS,
232232
bool onlySelected,
233233
QString *errorMessage,
234-
bool skipAttributeCreation,
235234
QMap<QString, QVariant> *options,
236235
QProgressDialog *progress )
237236
{
@@ -263,7 +262,7 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
263262
forceSinglePartGeom = options->take( QStringLiteral( "forceSinglePartGeometryType" ) ).toBool();
264263
}
265264

266-
QgsFields fields = skipAttributeCreation ? QgsFields() : layer->fields();
265+
QgsFields fields = layer->fields();
267266
QgsWkbTypes::Type wkbType = layer->wkbType();
268267

269268
// Special handling for Shapefiles
@@ -327,8 +326,6 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
327326
QgsFeatureRequest req;
328327
if ( wkbType == QgsWkbTypes::NoGeometry )
329328
req.setFlags( QgsFeatureRequest::NoGeometry );
330-
if ( skipAttributeCreation )
331-
req.setSubsetOfAttributes( QgsAttributeList() );
332329

333330
QgsFeatureIterator fit = layer->getFeatures( req );
334331

@@ -405,10 +402,6 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
405402
return ErrProjection;
406403
}
407404
}
408-
if ( skipAttributeCreation )
409-
{
410-
fet.initAttributes( 0 );
411-
}
412405
if ( !writer->addFeature( fet ) )
413406
{
414407
if ( writer->errorCode() && errorMessage )
@@ -504,7 +497,7 @@ bool QgsVectorLayerExporterTask::run()
504497

505498

506499
mError = QgsVectorLayerExporter::exportLayer(
507-
mLayer.data(), mDestUri, mDestProviderKey, mDestCrs, false, &mErrorMessage, false,
500+
mLayer.data(), mDestUri, mDestProviderKey, mDestCrs, false, &mErrorMessage,
508501
&mOptions );
509502

510503
if ( mOwnsLayer )

src/core/qgsvectorlayerexporter.h

-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ class CORE_EXPORT QgsVectorLayerExporter : public QgsFeatureSink
7474
* not available
7575
* \param onlySelected set to true to export only selected features
7676
* \param errorMessage if non-null, will be set to any error messages
77-
* \param skipAttributeCreation set to true to skip exporting feature attributes
7877
* \param options optional provider dataset options
7978
* \param progress optional progress dialog to show progress of export
8079
* \returns NoError for a successful export, or encountered error
@@ -85,7 +84,6 @@ class CORE_EXPORT QgsVectorLayerExporter : public QgsFeatureSink
8584
const QgsCoordinateReferenceSystem &destCRS,
8685
bool onlySelected = false,
8786
QString *errorMessage SIP_OUT = 0,
88-
bool skipAttributeCreation = false,
8987
QMap<QString, QVariant> *options = nullptr,
9088
QProgressDialog *progress = nullptr
9189
);

tests/src/python/test_provider_ogr_gpkg.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def testSimulatedDBManagerImport(self):
416416
options['update'] = True
417417
options['driverName'] = 'GPKG'
418418
options['layerName'] = 'my_out_table'
419-
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, False, options)
419+
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, options)
420420
self.assertEqual(err[0], QgsVectorLayerExporter.NoError,
421421
'unexpected import error {0}'.format(err))
422422
lyr = QgsVectorLayer(tmpfile + "|layername=my_out_table", "y", "ogr")
@@ -431,7 +431,7 @@ def testSimulatedDBManagerImport(self):
431431
features = None
432432

433433
# Test overwriting without overwrite option
434-
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, False, options)
434+
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, options)
435435
self.assertEqual(err[0], QgsVectorLayerExporter.ErrCreateDataSource)
436436

437437
# Test overwriting
@@ -441,7 +441,7 @@ def testSimulatedDBManagerImport(self):
441441
f['f1'] = 3
442442
lyr.dataProvider().addFeatures([f])
443443
options['overwrite'] = True
444-
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, False, options)
444+
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, options)
445445
self.assertEqual(err[0], QgsVectorLayerExporter.NoError,
446446
'unexpected import error {0}'.format(err))
447447
lyr = QgsVectorLayer(tmpfile + "|layername=my_out_table", "y", "ogr")

0 commit comments

Comments
 (0)