summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdir.cpp
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2010-08-31 07:56:27 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2010-09-07 12:17:10 (GMT)
commitb0de175aab06092932077eb1c5fb3f89691b6014 (patch)
tree234528d2f057de9e213d61f17a611836b952c366 /src/corelib/io/qdir.cpp
parent8e8743113f642e82bac6ecc055d2d3be8f53d7a6 (diff)
downloadQt-b0de175aab06092932077eb1c5fb3f89691b6014.zip
Qt-b0de175aab06092932077eb1c5fb3f89691b6014.tar.gz
Qt-b0de175aab06092932077eb1c5fb3f89691b6014.tar.bz2
QDir and QFileInfo shouldn't lose properties when detaching
For QFileInfo, the caching state was being lost on the different setFile overloads. QDir::cd and ::makeAbsolute were losing filters and sorting flags. QDir issues were introduced with these patches: "Simplify QDir::cd" "QDir::makeAbsolute could self-destruct on failure" Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'src/corelib/io/qdir.cpp')
-rw-r--r--src/corelib/io/qdir.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index b126c6d..6393509 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -136,6 +136,19 @@ public:
delete fileEngine;
}
+ bool exists() const
+ {
+ if (!fileEngine)
+ return false;
+ const QAbstractFileEngine::FileFlags info =
+ fileEngine->fileFlags(QAbstractFileEngine::DirectoryType
+ | QAbstractFileEngine::ExistsFlag
+ | QAbstractFileEngine::Refresh);
+ if (!(info & QAbstractFileEngine::DirectoryType))
+ return false;
+ return info & QAbstractFileEngine::ExistsFlag;
+ }
+
void initFileEngine();
void initFileLists() const;
@@ -891,11 +904,13 @@ bool QDir::cd(const QString &dirName)
}
}
- QDir dir(newPath);
- if (!dir.exists())
+ QScopedPointer<QDirPrivate> dir(new QDirPrivate(*d_ptr.constData()));
+ dir->setPath(newPath);
+
+ if (!dir->exists())
return false;
- *this = dir;
+ d_ptr = dir.take();
return true;
}
@@ -1495,17 +1510,7 @@ bool QDir::isReadable() const
*/
bool QDir::exists() const
{
- const QDirPrivate* d = d_ptr.constData();
-
- if (!d->fileEngine)
- return false;
- const QAbstractFileEngine::FileFlags info =
- d->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType
- | QAbstractFileEngine::ExistsFlag
- | QAbstractFileEngine::Refresh);
- if (!(info & QAbstractFileEngine::DirectoryType))
- return false;
- return info & QAbstractFileEngine::ExistsFlag;
+ return d_ptr->exists();
}
/*!
@@ -1579,11 +1584,13 @@ bool QDir::makeAbsolute() // ### What do the return values signify?
if (QDir::isRelativePath(absolutePath))
return false;
- QDir dir(absolutePath);
- if (!(dir.d_ptr.constData()->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType))
+ QScopedPointer<QDirPrivate> dir(new QDirPrivate(*d_ptr.constData()));
+ dir->setPath(absolutePath);
+
+ if (!(dir->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType))
return false;
- *this = dir;
+ d_ptr = dir.take();
return true;
}