summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdir.cpp
diff options
context:
space:
mode:
authorJoão Abecasis <joao@trolltech.com>2010-02-11 16:31:53 (GMT)
committerJoão Abecasis <joao@trolltech.com>2010-02-11 17:57:11 (GMT)
commit0601f9f764c55390a2cdd71d91c3ea25c57f2a6d (patch)
tree149d9c1694c6fdd012ac2cb8b9791c9144cb4fd7 /src/corelib/io/qdir.cpp
parentebfb42a9ada20c93643b05ebbb73709bd639742d (diff)
downloadQt-0601f9f764c55390a2cdd71d91c3ea25c57f2a6d.zip
Qt-0601f9f764c55390a2cdd71d91c3ea25c57f2a6d.tar.gz
Qt-0601f9f764c55390a2cdd71d91c3ea25c57f2a6d.tar.bz2
Fix bug in QDirPrivate::setPath, affecting QDir::cd, cdUp and setPath
The changes introduced in 9d713d7e73a88fe8328b55d2ab9af8c215dcb89d made QDirPrivate rely on the order of sub-expression evaluation. In some platform/compiler combinations, the instance of QDirPrivate::Data::path being changed would be the pre-detach one. With this change, that commit is partially reverted. Also, inlined the code in initFileEngine since this makes the actions therein explicit. Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/corelib/io/qdir.cpp')
-rw-r--r--src/corelib/io/qdir.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index f5d803e..7cfdddf 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -89,8 +89,6 @@ public:
QDirPrivate(const QDir *copy = 0);
~QDirPrivate();
- QString initFileEngine(const QString &file);
-
void updateFileLists() const;
void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *) const;
@@ -146,6 +144,7 @@ public:
} *data;
inline void setPath(const QString &p)
{
+ detach(false);
QString path = p;
if ((path.endsWith(QLatin1Char('/')) || path.endsWith(QLatin1Char('\\')))
&& path.length() > 1) {
@@ -155,8 +154,12 @@ public:
path.truncate(path.length() - 1);
}
+ delete data->fileEngine;
+ data->fileEngine = QAbstractFileEngine::create(path);
+
// set the path to be the qt friendly version so then we can operate on it using just /
- data->path = initFileEngine(path);
+ data->path = data->fileEngine->fileName(QAbstractFileEngine::DefaultName);
+ data->clear();
}
inline void reset() {
detach();
@@ -310,15 +313,6 @@ inline void QDirPrivate::updateFileLists() const
}
}
-inline QString QDirPrivate::initFileEngine(const QString &path)
-{
- detach(false);
- data->clear();
- delete data->fileEngine;
- data->fileEngine = QAbstractFileEngine::create(path);
- return data->fileEngine->fileName(QAbstractFileEngine::DefaultName);
-}
-
void QDirPrivate::detach(bool createFileEngine)
{
qAtomicDetach(data);