Skip to content

Commit

Permalink
fix #3945 (following up on r15148)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@15178 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 16, 2011
1 parent 2464884 commit 98d204b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -42,6 +42,14 @@
#include <cpl_error.h>
#include <cpl_conv.h>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8(x) (x).toUtf8().constData()
#define TO8F(x) (x).toUtf8().constData()
#else
#define TO8(x) (x).toLocal8Bit().constData()
#define TO8F(x) QFile::encodeName( x ).constData()
#endif


QgsVectorFileWriter::QgsVectorFileWriter(
const QString &theVectorFileName,
Expand Down Expand Up @@ -144,7 +152,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
}

// create the data source
mDS = OGR_Dr_CreateDataSource( poDriver, vectorFileName.toLocal8Bit().data(), options );
mDS = OGR_Dr_CreateDataSource( poDriver, TO8( vectorFileName ), options );

if ( options )
{
Expand Down Expand Up @@ -202,7 +210,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(
options[ layerOptions.size()] = NULL;
}

mLayer = OGR_DS_CreateLayer( mDS, QFile::encodeName( layerName ).data(), ogrRef, wkbType, options );
mLayer = OGR_DS_CreateLayer( mDS, TO8F( layerName ), ogrRef, wkbType, options );

if ( options )
{
Expand Down
4 changes: 2 additions & 2 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -1622,7 +1622,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
}

OGRDataSourceH dataSource;
dataSource = OGR_Dr_CreateDataSource( driver, QFile::encodeName( uri ).constData(), NULL );
dataSource = OGR_Dr_CreateDataSource( driver, TO8F( uri ), NULL );
if ( dataSource == NULL )
{
return false;
Expand Down Expand Up @@ -1679,7 +1679,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
}

OGRLayerH layer;
layer = OGR_DS_CreateLayer( dataSource, QFile::encodeName( QFileInfo( uri ).completeBaseName() ).constData(), reference, OGRvectortype, NULL );
layer = OGR_DS_CreateLayer( dataSource, TO8F( QFileInfo( uri ).completeBaseName() ), reference, OGRvectortype, NULL );
if ( layer == NULL )
{
return false;
Expand Down

0 comments on commit 98d204b

Please sign in to comment.