diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2010-08-26 11:49:31 (GMT) |
---|---|---|
committer | João Abecasis <joao.abecasis@nokia.com> | 2010-08-27 13:47:26 (GMT) |
commit | fdec31a2e57c7da48be741c14bedaaff4b95e7af (patch) | |
tree | 212f88c185e9af1bb20f9c9b363166e167c4d5a8 /src | |
parent | 1b201e0857d8232eeb1c25942c4fad9360cc11c3 (diff) | |
download | Qt-fdec31a2e57c7da48be741c14bedaaff4b95e7af.zip Qt-fdec31a2e57c7da48be741c14bedaaff4b95e7af.tar.gz Qt-fdec31a2e57c7da48be741c14bedaaff4b95e7af.tar.bz2 |
QDir::makeAbsolute could self-destruct on failure
makeAbsolute would return false if the newly constructed file engine
reported it wasn't referencing a directory. At this point, the private
data has already been updated, rendering the instance unusable.
Instead, we now create a separate QDir instance and reset our private
data only on success. Similarly to what's done in QDir::cd.
Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qdir.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 3587243..1da4f82 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1585,14 +1585,11 @@ bool QDir::makeAbsolute() // ### What do the return values signify? if (QDir::isRelativePath(absolutePath)) return false; - Q_D(QDir); - - d->path = absolutePath; - d->initFileEngine(); - d->clearFileLists(); - - if (!(d->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) + QDir dir(absolutePath); + if (!(dir.d_ptr.constData()->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) return false; + + *this = dir; return true; } |