Utils: Simplify FilePath::toFileInfo().lastModified() calls

It's the same as FilePath::lastModified locally, and toFileInfo
doesn't work remotely. So it's overall at least not worse.

Change-Id: Ice8d80dcfd01dc38edc1dce2b53e1b5e6274380f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2021-06-17 17:25:38 +02:00
parent 193f485be2
commit c0fe038f93
8 changed files with 12 additions and 12 deletions

View File

@@ -839,7 +839,7 @@ namespace ADS
if (!fi.exists() || fi.copy(workspaceNameToFilePath(clone).toString())) { if (!fi.exists() || fi.copy(workspaceNameToFilePath(clone).toString())) {
d->m_workspaces.insert(1, clone); d->m_workspaces.insert(1, clone);
d->m_workspaceDateTimes d->m_workspaceDateTimes
.insert(clone, workspaceNameToFilePath(clone).toFileInfo().lastModified()); .insert(clone, workspaceNameToFilePath(clone).lastModified());
emit workspaceListChanged(); emit workspaceListChanged();
return true; return true;
} }
@@ -918,7 +918,7 @@ namespace ADS
} else { } else {
d->m_workspaces.insert(1, workspaceName); d->m_workspaces.insert(1, workspaceName);
d->m_workspaceDateTimes.insert(workspaceName, d->m_workspaceDateTimes.insert(workspaceName,
workspaceNameToFilePath(workspaceName).toFileInfo().lastModified()); workspaceNameToFilePath(workspaceName).lastModified());
d->m_workspaceListDirty = true; d->m_workspaceListDirty = true;
// After importing the workspace, update the workspace list // After importing the workspace, update the workspace list
workspaces(); workspaces();

View File

@@ -279,7 +279,7 @@ void AndroidConfig::parseDependenciesJson()
QFile::copy(sdkConfigFile.toString(), sdkConfigUserFile.toString()); QFile::copy(sdkConfigFile.toString(), sdkConfigUserFile.toString());
} }
if (sdkConfigFile.toFileInfo().lastModified() > sdkConfigUserFile.toFileInfo().lastModified()) { if (sdkConfigFile.lastModified() > sdkConfigUserFile.lastModified()) {
const QString oldUserFile = (sdkConfigUserFile + ".old").toString(); const QString oldUserFile = (sdkConfigUserFile + ".old").toString();
QFile::remove(oldUserFile); QFile::remove(oldUserFile);
QFile::rename(sdkConfigUserFile.toString(), oldUserFile); QFile::rename(sdkConfigUserFile.toString(), oldUserFile);

View File

@@ -778,7 +778,7 @@ void DebuggerItemManagerPrivate::autoDetectGdbOrLldbDebuggers(const FilePath &de
return titem->m_item.command() == command; return titem->m_item.command() == command;
}; };
if (DebuggerTreeItem *existingItem = m_model->findItemAtLevel<2>(commandMatches)) { if (DebuggerTreeItem *existingItem = m_model->findItemAtLevel<2>(commandMatches)) {
if (command.toFileInfo().lastModified() != existingItem->m_item.lastModified()) if (command.lastModified() != existingItem->m_item.lastModified())
existingItem->m_item.reinitializeFromFile(); existingItem->m_item.reinitializeFromFile();
continue; continue;
} }

View File

@@ -473,8 +473,8 @@ void IosDebugSupport::start()
QString bundlePath = iosRunConfig->bundleDirectory().toString(); QString bundlePath = iosRunConfig->bundleDirectory().toString();
bundlePath.chop(4); bundlePath.chop(4);
FilePath dsymPath = FilePath::fromString(bundlePath.append(".dSYM")); FilePath dsymPath = FilePath::fromString(bundlePath.append(".dSYM"));
if (dsymPath.exists() && dsymPath.toFileInfo().lastModified() if (dsymPath.exists()
< QFileInfo(iosRunConfig->localExecutable().toUserOutput()).lastModified()) { && dsymPath.lastModified() < iosRunConfig->localExecutable().lastModified()) {
TaskHub::addTask(DeploymentTask(Task::Warning, TaskHub::addTask(DeploymentTask(Task::Warning,
tr("The dSYM %1 seems to be outdated, it might confuse the debugger.") tr("The dSYM %1 seems to be outdated, it might confuse the debugger.")
.arg(dsymPath.toUserOutput()))); .arg(dsymPath.toUserOutput())));

View File

@@ -104,7 +104,7 @@ ExtraCompiler::ExtraCompiler(const Project *project, const Utils::FilePath &sour
this, &ExtraCompiler::onEditorAboutToClose); this, &ExtraCompiler::onEditorAboutToClose);
// Use existing target files, where possible. Otherwise run the compiler. // Use existing target files, where possible. Otherwise run the compiler.
QDateTime sourceTime = d->source.toFileInfo().lastModified(); QDateTime sourceTime = d->source.lastModified();
foreach (const Utils::FilePath &target, targets) { foreach (const Utils::FilePath &target, targets) {
QFileInfo targetFileInfo(target.toFileInfo()); QFileInfo targetFileInfo(target.toFileInfo());
if (!targetFileInfo.exists()) { if (!targetFileInfo.exists()) {
@@ -180,7 +180,7 @@ void ExtraCompiler::onTargetsBuilt(Project *project)
// This is mostly a fall back for the cases when the generator couldn't be run. // This is mostly a fall back for the cases when the generator couldn't be run.
// It pays special attention to the case where a source file was newly created // It pays special attention to the case where a source file was newly created
const QDateTime sourceTime = d->source.toFileInfo().lastModified(); const QDateTime sourceTime = d->source.lastModified();
if (d->compileTime.isValid() && d->compileTime >= sourceTime) if (d->compileTime.isValid() && d->compileTime >= sourceTime)
return; return;

View File

@@ -872,7 +872,7 @@ bool SessionManager::cloneSession(const QString &original, const QString &clone)
// If the file does not exist, we can still clone // If the file does not exist, we can still clone
if (!fi.exists() || fi.copy(sessionNameToFileName(clone).toString())) { if (!fi.exists() || fi.copy(sessionNameToFileName(clone).toString())) {
d->m_sessions.insert(1, clone); d->m_sessions.insert(1, clone);
d->m_sessionDateTimes.insert(clone, sessionNameToFileName(clone).toFileInfo().lastModified()); d->m_sessionDateTimes.insert(clone, sessionNameToFileName(clone).lastModified());
return true; return true;
} }
return false; return false;

View File

@@ -110,7 +110,7 @@ QDateTime PuppetCreator::qtLastModified() const
{ {
QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_target->kit()); QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_target->kit());
if (currentQtVersion) if (currentQtVersion)
return currentQtVersion->libraryPath().toFileInfo().lastModified(); return currentQtVersion->libraryPath().lastModified();
return QDateTime(); return QDateTime();
} }

View File

@@ -109,14 +109,14 @@ void DeploymentTimeInfo::saveDeploymentTimeStamp(const DeployableFile &deployabl
{ {
d->lastDeployed.insert( d->lastDeployed.insert(
d->parameters(deployableFile, kit), d->parameters(deployableFile, kit),
{ deployableFile.localFilePath().toFileInfo().lastModified(), remoteTimestamp }); { deployableFile.localFilePath().lastModified(), remoteTimestamp });
} }
bool DeploymentTimeInfo::hasLocalFileChanged(const DeployableFile &deployableFile, bool DeploymentTimeInfo::hasLocalFileChanged(const DeployableFile &deployableFile,
const Kit *kit) const const Kit *kit) const
{ {
const auto &lastDeployed = d->lastDeployed.value(d->parameters(deployableFile, kit)); const auto &lastDeployed = d->lastDeployed.value(d->parameters(deployableFile, kit));
const QDateTime lastModified = deployableFile.localFilePath().toFileInfo().lastModified(); const QDateTime lastModified = deployableFile.localFilePath().lastModified();
return !lastDeployed.local.isValid() || lastModified != lastDeployed.local; return !lastDeployed.local.isValid() || lastModified != lastDeployed.local;
} }