Skip to content
Permalink
Browse files
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 4a03bd0c34e0fc83ebdef05ef22b100dfb5923fe
Showing with 9 additions and 7 deletions.
  1. +3 −1 src/plugins/georeferencer/qgsimagewarper.cpp
  2. +6 −6 src/raster/qgsrasterlayer.cpp
@@ -8,6 +8,8 @@
#include <gdalwarper.h>
#include <gdal_frmts.h>

#include <QFile>

#include "qgsimagewarper.h"


@@ -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();
@@ -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;
@@ -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)
{
@@ -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) {
@@ -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;
}

@@ -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;
}
@@ -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();
}

0 comments on commit 4a03bd0

Please sign in to comment.