[Qgis-developer] empty ds/layer creation duplicated in QgsOgrProvider and QgsVectorFileWriter

Giuseppe Sucameli brush.tyler at gmail.com
Sat Jul 14 06:40:55 PDT 2012


Hi devs,

today looking at the OGRProvider I've found some duplications:

QGISEXTERN bool createEmptyDataSource(...)
QGISEXTERN QgsVectorLayerImport::ImportError createEmptyLayer(...)

Both accomplish the same task (empty LAYER creation), but

createEmptyLayer() uses the QgsVectorFileWriter class,

createEmptyDataSource() contains code pretty similar to the one
within the QgsVectorFileWriter class (duplicated code).

The createEmptyLayer is used by the ImportVectorLayer feature
I developed for the GSoC the last year, so functions with the same
name are also present in both the PG and SL providers.
I don't know if the createEmptyDataSource() was already present at
that time (my apologize if it was)...

BTW having duplicated code between the provider and
QgsVectorFileWriter class is not good.
For this reason I called QgsVectorFileWriter methods from "my"
createEmptyLayer(), waiting for the API break to move the code
from QgsVectorFileWriter class to the OGR provider.

Is it time to break API or should we just clean it up removing
the createEmptyDataSource() function and replacing all its
occurrences (it's used in src/gui/qgsnewvectorlayerdialog.cpp only)
with the createEmptyLayer() function?

Regards.

-- 
Giuseppe Sucameli


More information about the Qgis-developer mailing list