From 4ceeeca71554b92563d42701bf5ffdb7b5b468d9 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 20 Aug 2021 17:18:59 +0200 Subject: [PATCH] Debugger: Remove some uses of FilePath::toFileInfo() Change-Id: I78037741084630fc6852f5805595ec2943db64d2 Reviewed-by: Artem Sokolovskii Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggeritem.cpp | 21 ++++++------------- src/plugins/debugger/debuggeritemmanager.cpp | 2 +- .../debugger/debuggerkitinformation.cpp | 10 ++++----- src/plugins/debugger/uvsc/uvscengine.cpp | 2 +- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/plugins/debugger/debuggeritem.cpp b/src/plugins/debugger/debuggeritem.cpp index 40c74a940df..36e066e09a1 100644 --- a/src/plugins/debugger/debuggeritem.cpp +++ b/src/plugins/debugger/debuggeritem.cpp @@ -143,31 +143,22 @@ void DebuggerItem::createId() m_id = QUuid::createUuid().toString(); } -static bool isUVisionExecutable(const QFileInfo &fileInfo) -{ - if (!HostOsInfo::isWindowsHost()) - return false; - const QString baseName = fileInfo.baseName(); - return baseName == "UV4"; -} - void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *error) { // CDB only understands the single-dash -version, whereas GDB and LLDB are // happy with both -version and --version. So use the "working" -version // except for the experimental LLDB-MI which insists on --version. QString version = "-version"; - const QFileInfo fileInfo = m_command.toFileInfo(); - m_lastModified = fileInfo.lastModified(); - if (fileInfo.baseName().toLower().contains("lldb-mi")) + m_lastModified = m_command.lastModified(); + if (m_command.baseName().toLower().contains("lldb-mi")) version = "--version"; // We don't need to start the uVision executable to // determine its version. - if (isUVisionExecutable(fileInfo)) { + if (HostOsInfo::isWindowsHost() && m_command.baseName() == "UV4") { QString errorMessage; m_version = winGetDLLVersion(WinDLLFileVersion, - fileInfo.absoluteFilePath(), + m_command.absoluteFilePath().path(), &errorMessage); m_engineType = UvscEngineType; m_abis.clear(); @@ -179,7 +170,7 @@ void DebuggerItem::reinitializeFromFile(const Environment &sysEnv, QString *erro if (HostOsInfo::isWindowsHost() && m_command.fileName().startsWith("lldb")) { QString errorMessage; m_version = winGetDLLVersion(WinDLLFileVersion, - fileInfo.absoluteFilePath(), + m_command.absoluteFilePath().path(), &errorMessage); m_engineType = LldbEngineType; m_abis = Abi::abisOfBinary(m_command); @@ -305,7 +296,7 @@ QIcon DebuggerItem::decoration() const { if (m_engineType == NoEngineType) return Icons::CRITICAL.icon(); - if (!m_command.toFileInfo().isExecutable()) + if (!m_command.isExecutableFile()) return Icons::WARNING.icon(); if (!m_workingDirectory.isEmpty() && !m_workingDirectory.isDir()) return Icons::WARNING.icon(); diff --git a/src/plugins/debugger/debuggeritemmanager.cpp b/src/plugins/debugger/debuggeritemmanager.cpp index 0f389fe3695..a21bfbc7f57 100644 --- a/src/plugins/debugger/debuggeritemmanager.cpp +++ b/src/plugins/debugger/debuggeritemmanager.cpp @@ -938,7 +938,7 @@ void DebuggerItemManagerPrivate::readDebuggers(const FilePath &fileName, bool is .arg(item.command().toUserOutput(), item.id().toString(), fileName.toUserOutput()); continue; } - if (!item.command().toFileInfo().isExecutable()) { + if (!item.command().isExecutableFile()) { qWarning() << QString("DebuggerItem \"%1\" (%2) read from \"%3\" dropped since the command is not executable.") .arg(item.command().toUserOutput(), item.id().toString(), fileName.toUserOutput()); continue; diff --git a/src/plugins/debugger/debuggerkitinformation.cpp b/src/plugins/debugger/debuggerkitinformation.cpp index d8e06e74e71..edc355469de 100644 --- a/src/plugins/debugger/debuggerkitinformation.cpp +++ b/src/plugins/debugger/debuggerkitinformation.cpp @@ -307,10 +307,10 @@ DebuggerKitAspect::ConfigurationErrors DebuggerKitAspect::configurationErrors(co return NoDebugger; ConfigurationErrors result = NoConfigurationError; - const QFileInfo fi = item->command().toFileInfo(); - if (!fi.exists() || fi.isDir()) + const FilePath debugger = item->command(); + if (!debugger.exists() || debugger.isDir()) result |= DebuggerNotFound; - else if (!fi.isExecutable()) + else if (!debugger.isExecutableFile()) result |= DebuggerNotExecutable; const Abi tcAbi = ToolChainKitAspect::targetAbi(k); @@ -321,13 +321,13 @@ DebuggerKitAspect::ConfigurationErrors DebuggerKitAspect::configurationErrors(co result |= DebuggerDoesNotMatch; } - if (!fi.exists() || fi.isDir()) { + if (!debugger.exists() || debugger.isDir()) { if (item->engineType() == NoEngineType) return NoDebugger; // We need an absolute path to be able to locate Python on Windows. if (item->engineType() == GdbEngineType) { - if (tcAbi.os() == Abi::WindowsOS && !fi.isAbsolute()) + if (tcAbi.os() == Abi::WindowsOS && !debugger.isAbsolutePath()) result |= DebuggerNeedsAbsolutePath; } } diff --git a/src/plugins/debugger/uvsc/uvscengine.cpp b/src/plugins/debugger/uvsc/uvscengine.cpp index 475a205881b..915a6c970bd 100644 --- a/src/plugins/debugger/uvsc/uvscengine.cpp +++ b/src/plugins/debugger/uvsc/uvscengine.cpp @@ -68,7 +68,7 @@ constexpr int kRootStackFrameLevel = 1; static void allowRootLocals(const FilePath &projectFile) { const QFileInfo fi(projectFile.toFileInfo()); - if (!fi.exists()) + if (!projectFile.exists()) return; const QString baseName = fi.baseName(); const QDir dir(fi.dir());