Skip to content

Commit 94b9c13

Browse files
author
telwertowski
committed
Use QFile::encode to convert a QString containing a filename to a c-string. Mac expects Utf8 and *nix expects local8Bit. QFile will do the right thing for each platform and not mangle Mac non-ASCII filenames.
git-svn-id: http://svn.osgeo.org/qgis/trunk@5933 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ead5879 commit 94b9c13

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/gui/qgsvectorfilewriter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "qgsvectorfilewriter.h"
2020

2121
#include <iostream>
22+
#include <QFile>
2223
#include <QString>
2324
#include <QTextCodec>
2425

@@ -125,8 +126,8 @@ bool QgsVectorFileWriter::initialise()
125126
return false;
126127
}
127128

128-
// Filename needs toLocal8Bit().data()
129-
mDataSourceHandle = OGR_Dr_CreateDataSource( myDriverHandle, mOutputFileName.toLocal8Bit().data(), NULL );
129+
// Filename needs to be UTF-8 for Mac but local8Bit otherwise
130+
mDataSourceHandle = OGR_Dr_CreateDataSource( myDriverHandle, QFile::encodeName(mOutputFileName).constData(), NULL );
130131
if( mDataSourceHandle == NULL )
131132
{
132133
std::cout << "Datasource handle is null! " << std::endl;

src/providers/delimitedtext/qgsdelimitedtextprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ bool QgsDelimitedTextProvider::saveAsShapefile()
777777
}
778778
OGRDataSource *poDS;
779779
// create the data source
780-
poDS = poDriver->CreateDataSource((const char *) shapefileName.toLocal8Bit(), NULL);
780+
poDS = poDriver->CreateDataSource(QFile::encodeName(shapefileName).constData(), NULL);
781781
if (poDS != NULL)
782782
{
783783
QTextCodec* saveCodec = QTextCodec::codecForName(enc.toLocal8Bit().data());

src/providers/mysql/qgsmysqlprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ bool QgsMySQLProvider::saveAsShapefile()
843843
}
844844
OGRDataSource *poDS;
845845
// create the data source
846-
poDS = poDriver->CreateDataSource((const char *) shapefileName.toLocal8Bit(), NULL);
846+
poDS = poDriver->CreateDataSource(QFile::encodeName(shapefileName).constData(), NULL);
847847
if (poDS != NULL)
848848
{
849849
QTextCodec* saveCodec = QTextCodec::codecForName(enc.toLocal8Bit().data());

src/providers/ogr/qgsogrprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ const std::list<std::pair<QString, QString> >& attributes)
16411641
}
16421642

16431643
OGRDataSource* dataSource;
1644-
dataSource = driver->CreateDataSource(uri.toLocal8Bit(), NULL);
1644+
dataSource = driver->CreateDataSource(QFile::encodeName(uri).constData(), NULL);
16451645
if(dataSource == NULL)
16461646
{
16471647
return false;

0 commit comments

Comments
 (0)