From 9d713d7e73a88fe8328b55d2ab9af8c215dcb89d Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:41 +0100 Subject: QDirPrivate::setPath: always initialize the file engine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/corelib/io/qdir.cpp | 13 ++++--------- 1 file 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); } -- cgit v0.12