[QGIS Commit] r13589 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat May 29 07:39:19 EDT 2010


Author: jef
Date: 2010-05-29 07:39:19 -0400 (Sat, 29 May 2010)
New Revision: 13589

Modified:
   trunk/qgis/src/core/qgsvectorfilewriter.cpp
Log:
fix #2761

Modified: trunk/qgis/src/core/qgsvectorfilewriter.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorfilewriter.cpp	2010-05-29 11:03:30 UTC (rev 13588)
+++ trunk/qgis/src/core/qgsvectorfilewriter.cpp	2010-05-29 11:39:19 UTC (rev 13589)
@@ -41,15 +41,19 @@
 #include <cpl_error.h>
 
 
-QgsVectorFileWriter::QgsVectorFileWriter( const QString& vectorFileName,
-    const QString& fileEncoding,
-    const QgsFieldMap& fields,
-    QGis::WkbType geometryType,
-    const QgsCoordinateReferenceSystem* srs,
-    const QString& driverName )
-    : mDS( NULL ), mLayer( NULL ), mGeom( NULL ), mError( NoError )
+QgsVectorFileWriter::QgsVectorFileWriter(
+  const QString &theVectorFileName,
+  const QString& fileEncoding,
+  const QgsFieldMap& fields,
+  QGis::WkbType geometryType,
+  const QgsCoordinateReferenceSystem* srs,
+  const QString& driverName )
+    : mDS( NULL )
+    , mLayer( NULL )
+    , mGeom( NULL )
+    , mError( NoError )
 {
-  // save the layer as a shapefile
+  QString vectorFileName = theVectorFileName;
 
   // find driver in OGR
   OGRSFDriverH poDriver;
@@ -67,6 +71,11 @@
 
   if ( driverName == "ESRI Shapefile" )
   {
+    if ( !vectorFileName.endsWith( ".shp", Qt::CaseInsensitive ) )
+    {
+      vectorFileName += ".shp";
+    }
+
     // check for unique fieldnames
     QSet<QString> fieldNames;
     QgsFieldMap::const_iterator fldIt;
@@ -129,6 +138,7 @@
   {
     if ( driverName == "ESRI Shapefile" )
     {
+      QString layerName = vectorFileName.left( vectorFileName.indexOf( ".shp", Qt::CaseInsensitive ) );
       QFile prjFile( layerName + ".qpj" );
       if ( prjFile.open( QIODevice::WriteOnly ) )
       {



More information about the QGIS-commit mailing list