summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2010-01-29 12:12:41 (GMT)
committerJoão Abecasis <joao@trolltech.com>2010-01-29 12:12:41 (GMT)
commit9d713d7e73a88fe8328b55d2ab9af8c215dcb89d (patch)
tree3bb5ec73c311b5e8125cd1d447d6d57677a06e24
parentb915461519f1a4b7da8920203529e315eee39323 (diff)
downloadQt-9d713d7e73a88fe8328b55d2ab9af8c215dcb89d.zip
Qt-9d713d7e73a88fe8328b55d2ab9af8c215dcb89d.tar.gz
Qt-9d713d7e73a88fe8328b55d2ab9af8c215dcb89d.tar.bz2
QDirPrivate::setPath: always initialize the file engine
QDir::isRelativePath() would construct a temporary file engine just to check if we could reuse the existing one. This was also making assumptions about the inner workings of the engine, that might not be valid outside QFSFileEngine. Merge-request: 445 Reviewed-by: João Abecasis <joao@trolltech.com>
-rw-r--r--src/corelib/io/qdir.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index eb02e6c..06ea95a 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -147,7 +147,6 @@ private:
} *data;
inline void setPath(const QString &p)
{
- detach(false);
QString path = p;
if ((path.endsWith(QLatin1Char('/')) || path.endsWith(QLatin1Char('\\')))
&& path.length() > 1) {
@@ -156,12 +155,9 @@ private:
#endif
path.truncate(path.length() - 1);
}
- if(!data->fileEngine || !QDir::isRelativePath(path))
- path = initFileEngine(path);
- data->fileEngine->setFileName(path);
+
// set the path to be the qt friendly version so then we can operate on it using just /
- data->path = data->fileEngine->fileName(QAbstractFileEngine::DefaultName);
- data->clear();
+ data->path = initFileEngine(path);
}
inline void reset() {
detach();
@@ -318,12 +314,11 @@ inline void QDirPrivate::updateFileLists() const
}
}
-QString QDirPrivate::initFileEngine(const QString &path)
+inline QString QDirPrivate::initFileEngine(const QString &path)
{
detach(false);
- delete data->fileEngine;
- data->fileEngine = 0;
data->clear();
+ delete data->fileEngine;
data->fileEngine = QAbstractFileEngine::create(path);
return data->fileEngine->fileName(QAbstractFileEngine::DefaultName);
}