Skip to content

Commit 98d204b

Browse files
author
jef
committed
fix #3945 (following up on r15148)
git-svn-id: http://svn.osgeo.org/qgis/trunk@15178 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2464884 commit 98d204b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/core/qgsvectorfilewriter.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
#include <cpl_error.h>
4343
#include <cpl_conv.h>
4444

45+
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
46+
#define TO8(x) (x).toUtf8().constData()
47+
#define TO8F(x) (x).toUtf8().constData()
48+
#else
49+
#define TO8(x) (x).toLocal8Bit().constData()
50+
#define TO8F(x) QFile::encodeName( x ).constData()
51+
#endif
52+
4553

4654
QgsVectorFileWriter::QgsVectorFileWriter(
4755
const QString &theVectorFileName,
@@ -144,7 +152,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
144152
}
145153

146154
// create the data source
147-
mDS = OGR_Dr_CreateDataSource( poDriver, vectorFileName.toLocal8Bit().data(), options );
155+
mDS = OGR_Dr_CreateDataSource( poDriver, TO8( vectorFileName ), options );
148156

149157
if ( options )
150158
{
@@ -202,7 +210,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
202210
options[ layerOptions.size()] = NULL;
203211
}
204212

205-
mLayer = OGR_DS_CreateLayer( mDS, QFile::encodeName( layerName ).data(), ogrRef, wkbType, options );
213+
mLayer = OGR_DS_CreateLayer( mDS, TO8F( layerName ), ogrRef, wkbType, options );
206214

207215
if ( options )
208216
{

src/providers/ogr/qgsogrprovider.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
16221622
}
16231623

16241624
OGRDataSourceH dataSource;
1625-
dataSource = OGR_Dr_CreateDataSource( driver, QFile::encodeName( uri ).constData(), NULL );
1625+
dataSource = OGR_Dr_CreateDataSource( driver, TO8F( uri ), NULL );
16261626
if ( dataSource == NULL )
16271627
{
16281628
return false;
@@ -1679,7 +1679,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
16791679
}
16801680

16811681
OGRLayerH layer;
1682-
layer = OGR_DS_CreateLayer( dataSource, QFile::encodeName( QFileInfo( uri ).completeBaseName() ).constData(), reference, OGRvectortype, NULL );
1682+
layer = OGR_DS_CreateLayer( dataSource, TO8F( QFileInfo( uri ).completeBaseName() ), reference, OGRvectortype, NULL );
16831683
if ( layer == NULL )
16841684
{
16851685
return false;

0 commit comments

Comments
 (0)