diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-09-06 15:43:29 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2011-09-07 12:07:35 (GMT) |
commit | ad35d25e78c8252a72108a4ba931934047c4707e (patch) | |
tree | 9d1b6320c0b00dfe1c5194c62f641f3b43d2d1df /src/corelib/io/qdir.cpp | |
parent | 64adbd0c5775f97343afbe0e7b5fde0d70bdaedd (diff) | |
download | Qt-ad35d25e78c8252a72108a4ba931934047c4707e.zip Qt-ad35d25e78c8252a72108a4ba931934047c4707e.tar.gz Qt-ad35d25e78c8252a72108a4ba931934047c4707e.tar.bz2 |
Merge fixes for QDir::operator==
There were two fixes in 4.8 which each fixed a part of the problem.
Comparing canonical paths is more correct, but is only possible where
both directories exist. If neither directory exists, then compare
absolute paths instead.
Changed a regression test, because /tmp is a symbolic link on MacOS.
I.E. "/tmp/.." is canonically "/private" and not "/" as expected.
Task-Number: QTBUG-20495
Reviewed-By: joao
Diffstat (limited to 'src/corelib/io/qdir.cpp')
-rw-r--r-- | src/corelib/io/qdir.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 3271148..9081e31 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1638,8 +1638,19 @@ bool QDir::operator==(const QDir &dir) const if (d->dirEntry.filePath() == other->dirEntry.filePath()) return true; - // Fallback to expensive canonical path computation - return canonicalPath().compare(dir.canonicalPath(), sensitive) == 0; + if (exists()) { + if (!dir.exists()) + return false; //can't be equal if only one exists + // Both exist, fallback to expensive canonical path computation + return canonicalPath().compare(dir.canonicalPath(), sensitive) == 0; + } else { + if (dir.exists()) + return false; //can't be equal if only one exists + // Neither exists, compare absolute paths rather than canonical (which would be empty strings) + d->resolveAbsoluteEntry(); + other->resolveAbsoluteEntry(); + return d->absoluteDirEntry.filePath().compare(other->absoluteDirEntry.filePath(), sensitive) == 0; + } } return false; } |