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-09-07 12:17:04 (GMT) |
commit | 4c88ffbbf0de319bcb4aef54be3997bb41a08100 (patch) | |
tree | 81d7a20ee0132babb684e60d0119a0c8e99ba01e /src/corelib/io/qdir.cpp | |
parent | c3c30e16a2bb5ab9236946aa6c48ca02ef2afa08 (diff) | |
download | Qt-4c88ffbbf0de319bcb4aef54be3997bb41a08100.zip Qt-4c88ffbbf0de319bcb4aef54be3997bb41a08100.tar.gz Qt-4c88ffbbf0de319bcb4aef54be3997bb41a08100.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/corelib/io/qdir.cpp')
-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 b35cd2b..5ae54fc 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; } |