FilePath: Use isSameDevice

Some places compared the scheme and host of a filepath to
decide whether its the same device. This is incorrect and
leads to false negatives. isSameDevice is the correct way
to decide whether two paths are from the same device.

Fixes: QTCREATORBUG-29474
Change-Id: Iced8f434dadb931f6595f47f95647b341c48d3aa
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-08-08 13:43:19 +02:00
parent 467d94b7f4
commit 31f7ed44b6
3 changed files with 3 additions and 4 deletions

View File

@@ -722,8 +722,7 @@ bool FileUtils::copyRecursively(
bool FileUtils::copyIfDifferent(const FilePath &srcFilePath, const FilePath &tgtFilePath) bool FileUtils::copyIfDifferent(const FilePath &srcFilePath, const FilePath &tgtFilePath)
{ {
QTC_ASSERT(srcFilePath.exists(), return false); QTC_ASSERT(srcFilePath.exists(), return false);
QTC_ASSERT(srcFilePath.scheme() == tgtFilePath.scheme(), return false); QTC_ASSERT(srcFilePath.isSameDevice(tgtFilePath), return false);
QTC_ASSERT(srcFilePath.host() == tgtFilePath.host(), return false);
if (tgtFilePath.exists()) { if (tgtFilePath.exists()) {
const QDateTime srcModified = srcFilePath.lastModified(); const QDateTime srcModified = srcFilePath.lastModified();

View File

@@ -1204,7 +1204,7 @@ FilePath Process::workingDirectory() const
void Process::setWorkingDirectory(const FilePath &dir) void Process::setWorkingDirectory(const FilePath &dir)
{ {
if (dir.needsDevice() && d->m_setup.m_commandLine.executable().needsDevice()) { if (dir.needsDevice() && d->m_setup.m_commandLine.executable().needsDevice()) {
QTC_CHECK(dir.host() == d->m_setup.m_commandLine.executable().host()); QTC_CHECK(dir.isSameDevice(d->m_setup.m_commandLine.executable()));
} }
d->m_setup.m_workingDirectory = dir; d->m_setup.m_workingDirectory = dir;
} }

View File

@@ -79,7 +79,7 @@ void CMakeProcess::run(const BuildDirParameters &parameters, const QStringList &
} }
if (buildDirectory.needsDevice()) { if (buildDirectory.needsDevice()) {
if (cmake->cmakeExecutable().host() != buildDirectory.host()) { if (!cmake->cmakeExecutable().isSameDevice(buildDirectory)) {
const QString msg = ::CMakeProjectManager::Tr::tr( const QString msg = ::CMakeProjectManager::Tr::tr(
"CMake executable \"%1\" and build directory \"%2\" must be on the same device.") "CMake executable \"%1\" and build directory \"%2\" must be on the same device.")
.arg(cmake->cmakeExecutable().toUserOutput(), buildDirectory.toUserOutput()); .arg(cmake->cmakeExecutable().toUserOutput(), buildDirectory.toUserOutput());