Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use QFile::encode to convert a QString containing a filename to a c-s…
…tring. 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@5589 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
telwertowski committed Jul 13, 2006
1 parent afff4af commit 4a03bd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/plugins/georeferencer/qgsimagewarper.cpp
Expand Up @@ -8,6 +8,8 @@
#include <gdalwarper.h>
#include <gdal_frmts.h>

#include <QFile>

#include "qgsimagewarper.h"


Expand All @@ -19,7 +21,7 @@ void QgsImageWarper::warp(const QString& input, const QString& output,
ResamplingMethod resampling, bool useZeroAsTrans) {
// Open input file
GDALAllRegister();
GDALDataset* hSrcDS = static_cast<GDALDataset*>(GDALOpen((const char*)input,
GDALDataset* hSrcDS = static_cast<GDALDataset*>(GDALOpen(QFile::encodeName(input).constData(),
GA_ReadOnly));
// Setup warp options.
GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();
Expand Down
12 changes: 6 additions & 6 deletions src/raster/qgsrasterlayer.cpp
Expand Up @@ -388,7 +388,7 @@ bool QgsRasterLayer::isValidRasterFileName(QString const & theFileNameQString)
GDALAllRegister();

//open the file using gdal making sure we have handled locale properly
myDataset = GDALOpen( (const char*)(theFileNameQString.toLocal8Bit().data()), GA_ReadOnly );
myDataset = GDALOpen( QFile::encodeName(theFileNameQString).constData(), GA_ReadOnly );
if( myDataset == NULL )
{
return false;
Expand Down Expand Up @@ -489,7 +489,7 @@ QgsRasterLayer::readFile( QString const & fileName )
GDALAllRegister();

//open the dataset making sure we handle char encoding of locale properly
gdalDataset = (GDALDataset *) GDALOpen((const char*)(fileName.toLocal8Bit().data()), GA_ReadOnly);
gdalDataset = (GDALDataset *) GDALOpen(QFile::encodeName(fileName).constData(), GA_ReadOnly);

if (gdalDataset == NULL)
{
Expand Down Expand Up @@ -4132,7 +4132,7 @@ void QgsRasterLayer::buildPyramids(RasterPyramidList const & theRasterPyramidLis
GDALAllRegister();
//close the gdal dataset and reopen it in read / write mode
delete gdalDataset;
gdalDataset = (GDALDataset *) GDALOpen(dataSource.toLocal8Bit().data(), GA_Update);
gdalDataset = (GDALDataset *) GDALOpen(QFile::encodeName(dataSource).constData(), GA_Update);

// if the dataset couldn't be opened in read / write mode, tell the user
if (!gdalDataset) {
Expand All @@ -4145,7 +4145,7 @@ void QgsRasterLayer::buildPyramids(RasterPyramidList const & theRasterPyramidLis
Qt::NoButton,
Qt::NoButton );
myMessageBox.exec();
gdalDataset = (GDALDataset *) GDALOpen(dataSource.toLocal8Bit().data(), GA_ReadOnly);
gdalDataset = (GDALDataset *) GDALOpen(QFile::encodeName(dataSource).constData(), GA_ReadOnly);
return;
}

Expand Down Expand Up @@ -4215,7 +4215,7 @@ void QgsRasterLayer::buildPyramids(RasterPyramidList const & theRasterPyramidLis
Qt::NoButton );
myMessageBox.exec();
delete gdalDataset;
gdalDataset = (GDALDataset *) GDALOpen(dataSource.toLocal8Bit().data(), GA_ReadOnly);
gdalDataset = (GDALDataset *) GDALOpen(QFile::encodeName(dataSource).constData(), GA_ReadOnly);
emit setProgress(0,0);
return;
}
Expand All @@ -4232,7 +4232,7 @@ void QgsRasterLayer::buildPyramids(RasterPyramidList const & theRasterPyramidLis
QgsDebugMsg("Pyramid overviews built");
//close the gdal dataset and reopen it in read only mode
delete gdalDataset;
gdalDataset = (GDALDataset *) GDALOpen(dataSource.toLocal8Bit().data(), GA_ReadOnly);
gdalDataset = (GDALDataset *) GDALOpen(QFile::encodeName(dataSource).constData(), GA_ReadOnly);
emit setProgress(0,0);
QApplication::restoreOverrideCursor();
}
Expand Down

0 comments on commit 4a03bd0

Please sign in to comment.