Valgrind: Some more direct FilePath use

Change-Id: I99db6996482cd5a14dcc4d68c55b22c64feef9fa
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-10 13:14:07 +02:00
parent 6ad4761604
commit 9e84b09e99
2 changed files with 11 additions and 9 deletions

View File

@@ -361,7 +361,7 @@ CallgrindToolPrivate::CallgrindToolPrivate()
action->setIcon(kCachegrindIcon.icon()); action->setIcon(kCachegrindIcon.icon());
action->setToolTip(Tr::tr("Open results in KCachegrind.")); action->setToolTip(Tr::tr("Open results in KCachegrind."));
connect(action, &QAction::triggered, this, [this, settings] { connect(action, &QAction::triggered, this, [this, settings] {
Process::startDetached({FilePath::fromString(settings->kcachegrindExecutable.value()), { m_lastFileName }}); Process::startDetached({settings->kcachegrindExecutable(), { m_lastFileName }});
}); });
// dump action // dump action
@@ -908,10 +908,10 @@ void CallgrindToolPrivate::takeParserData(ParseData *data)
doClear(true); doClear(true);
setParseData(data); setParseData(data);
const QString kcachegrindExecutable = const FilePath kcachegrindExecutable =
ValgrindGlobalSettings::instance()->kcachegrindExecutable.value(); ValgrindGlobalSettings::instance()->kcachegrindExecutable();
const bool kcachegrindExists = !Utils::Environment::systemEnvironment().searchInPath( const FilePath found = kcachegrindExecutable.searchInPath();
kcachegrindExecutable).isEmpty(); const bool kcachegrindExists = found.isExecutableFile();
m_startKCachegrind->setEnabled(kcachegrindExists && !m_lastFileName.isEmpty()); m_startKCachegrind->setEnabled(kcachegrindExists && !m_lastFileName.isEmpty());
createTextMarks(); createTextMarks();
} }

View File

@@ -144,11 +144,13 @@ void ValgrindToolRunner::runnerFinished()
void ValgrindToolRunner::receiveProcessError(const QString &message, QProcess::ProcessError error) void ValgrindToolRunner::receiveProcessError(const QString &message, QProcess::ProcessError error)
{ {
if (error == QProcess::FailedToStart) { if (error == QProcess::FailedToStart) {
const QString valgrind = m_settings.valgrindExecutable.value(); const FilePath valgrind = m_settings.valgrindExecutable();
if (!valgrind.isEmpty()) if (!valgrind.isEmpty()) {
appendMessage(Tr::tr("Error: \"%1\" could not be started: %2").arg(valgrind, message), ErrorMessageFormat); appendMessage(Tr::tr("Error: \"%1\" could not be started: %2")
else .arg(valgrind.toUserOutput(), message), ErrorMessageFormat);
} else {
appendMessage(Tr::tr("Error: no Valgrind executable set."), ErrorMessageFormat); appendMessage(Tr::tr("Error: no Valgrind executable set."), ErrorMessageFormat);
}
} else if (m_isStopping && error == QProcess::Crashed) { // process gets killed on stop } else if (m_isStopping && error == QProcess::Crashed) { // process gets killed on stop
appendMessage(Tr::tr("Process terminated."), ErrorMessageFormat); appendMessage(Tr::tr("Process terminated."), ErrorMessageFormat);
} else { } else {