Skip to content

Commit 731c5b5

Browse files
author
jef
committed
fix #2761
git-svn-id: http://svn.osgeo.org/qgis/trunk@13589 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent c410f69 commit 731c5b5

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/core/qgsvectorfilewriter.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,19 @@
4141
#include <cpl_error.h>
4242

4343

44-
QgsVectorFileWriter::QgsVectorFileWriter( const QString& vectorFileName,
45-
const QString& fileEncoding,
46-
const QgsFieldMap& fields,
47-
QGis::WkbType geometryType,
48-
const QgsCoordinateReferenceSystem* srs,
49-
const QString& driverName )
50-
: mDS( NULL ), mLayer( NULL ), mGeom( NULL ), mError( NoError )
44+
QgsVectorFileWriter::QgsVectorFileWriter(
45+
const QString &theVectorFileName,
46+
const QString& fileEncoding,
47+
const QgsFieldMap& fields,
48+
QGis::WkbType geometryType,
49+
const QgsCoordinateReferenceSystem* srs,
50+
const QString& driverName )
51+
: mDS( NULL )
52+
, mLayer( NULL )
53+
, mGeom( NULL )
54+
, mError( NoError )
5155
{
52-
// save the layer as a shapefile
56+
QString vectorFileName = theVectorFileName;
5357

5458
// find driver in OGR
5559
OGRSFDriverH poDriver;
@@ -67,6 +71,11 @@ QgsVectorFileWriter::QgsVectorFileWriter( const QString& vectorFileName,
6771

6872
if ( driverName == "ESRI Shapefile" )
6973
{
74+
if ( !vectorFileName.endsWith( ".shp", Qt::CaseInsensitive ) )
75+
{
76+
vectorFileName += ".shp";
77+
}
78+
7079
// check for unique fieldnames
7180
QSet<QString> fieldNames;
7281
QgsFieldMap::const_iterator fldIt;
@@ -129,6 +138,7 @@ QgsVectorFileWriter::QgsVectorFileWriter( const QString& vectorFileName,
129138
{
130139
if ( driverName == "ESRI Shapefile" )
131140
{
141+
QString layerName = vectorFileName.left( vectorFileName.indexOf( ".shp", Qt::CaseInsensitive ) );
132142
QFile prjFile( layerName + ".qpj" );
133143
if ( prjFile.open( QIODevice::WriteOnly ) )
134144
{

0 commit comments

Comments
 (0)