forked from qt-creator/qt-creator
ProjectExplorer: Reuse StringUtils::joinStrings()
Do some minor cleanup. Change-Id: I375cec2cd4e0def201c09f5ad9eea4226a5d64e6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <utils/portlist.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/url.h>
|
||||
|
||||
using namespace Utils;
|
||||
@@ -30,10 +31,10 @@ public:
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
DeviceUsedPortsGatherer::DeviceUsedPortsGatherer(QObject *parent) :
|
||||
QObject(parent), d(new Internal::DeviceUsedPortsGathererPrivate)
|
||||
{
|
||||
}
|
||||
DeviceUsedPortsGatherer::DeviceUsedPortsGatherer(QObject *parent)
|
||||
: QObject(parent)
|
||||
, d(new Internal::DeviceUsedPortsGathererPrivate)
|
||||
{}
|
||||
|
||||
DeviceUsedPortsGatherer::~DeviceUsedPortsGatherer()
|
||||
{
|
||||
@@ -56,8 +57,7 @@ void DeviceUsedPortsGatherer::start()
|
||||
d->process.reset(new QtcProcess);
|
||||
d->process->setCommand(d->portsGatheringMethod.commandLine(protocol));
|
||||
|
||||
connect(d->process.get(), &QtcProcess::done,
|
||||
this, &DeviceUsedPortsGatherer::handleProcessDone);
|
||||
connect(d->process.get(), &QtcProcess::done, this, &DeviceUsedPortsGatherer::handleProcessDone);
|
||||
d->process->start();
|
||||
}
|
||||
|
||||
@@ -107,13 +107,11 @@ void DeviceUsedPortsGatherer::handleProcessDone()
|
||||
if (d->process->result() == ProcessResult::FinishedWithSuccess) {
|
||||
setupUsedPorts();
|
||||
} else {
|
||||
QString errMsg = d->process->errorString();
|
||||
const QByteArray stdErr = d->process->readAllRawStandardError();
|
||||
if (!stdErr.isEmpty()) {
|
||||
errMsg += QLatin1Char('\n');
|
||||
errMsg += Tr::tr("Remote error output was: %1").arg(QString::fromUtf8(stdErr));
|
||||
}
|
||||
emitError(errMsg);
|
||||
const QString errorString = d->process->errorString();
|
||||
const QString stdErr = d->process->readAllStandardError();
|
||||
const QString outputString
|
||||
= stdErr.isEmpty() ? stdErr : Tr::tr("Remote error output was: %1").arg(stdErr);
|
||||
emitError(Utils::joinStrings({errorString, outputString}, '\n'));
|
||||
}
|
||||
stop();
|
||||
}
|
||||
@@ -139,8 +137,6 @@ PortsGatherer::PortsGatherer(RunControl *runControl)
|
||||
});
|
||||
}
|
||||
|
||||
PortsGatherer::~PortsGatherer() = default;
|
||||
|
||||
void PortsGatherer::start()
|
||||
{
|
||||
appendMessage(Tr::tr("Checking available ports..."), NormalMessageFormat);
|
||||
@@ -260,7 +256,7 @@ QUrl ChannelProvider::channel(int i) const
|
||||
{
|
||||
if (Internal::SubChannelProvider *provider = m_channelProviders.value(i))
|
||||
return provider->channel();
|
||||
return QUrl();
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -44,7 +44,7 @@ private:
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT DeviceUsedPortsGathererAdapter
|
||||
: public Utils::Tasking::TaskAdapter<DeviceUsedPortsGatherer>
|
||||
: public Utils::Tasking::TaskAdapter<DeviceUsedPortsGatherer>
|
||||
{
|
||||
public:
|
||||
DeviceUsedPortsGathererAdapter();
|
||||
@@ -57,7 +57,6 @@ class PROJECTEXPLORER_EXPORT PortsGatherer : public RunWorker
|
||||
|
||||
public:
|
||||
explicit PortsGatherer(RunControl *runControl);
|
||||
~PortsGatherer() override;
|
||||
|
||||
QUrl findEndPoint();
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <utils/processinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
@@ -50,13 +51,13 @@ void SshDeviceProcessList::handleProcessDone()
|
||||
if (d->m_process.result() == ProcessResult::FinishedWithSuccess) {
|
||||
reportProcessListUpdated(buildProcessList(d->m_process.cleanedStdOut()));
|
||||
} else {
|
||||
const QString errorMessage = d->m_process.exitStatus() == QProcess::NormalExit
|
||||
const QString errorString = d->m_process.exitStatus() == QProcess::NormalExit
|
||||
? Tr::tr("Process listing command failed with exit code %1.").arg(d->m_process.exitCode())
|
||||
: d->m_process.errorString();
|
||||
const QString stdErr = d->m_process.cleanedStdErr();
|
||||
const QString fullMessage = stdErr.isEmpty()
|
||||
? errorMessage : errorMessage + '\n' + Tr::tr("Remote stderr was: %1").arg(stdErr);
|
||||
reportError(fullMessage);
|
||||
const QString outputString
|
||||
= stdErr.isEmpty() ? stdErr : Tr::tr("Remote stderr was: %1").arg(stdErr);
|
||||
reportError(Utils::joinStrings({errorString, outputString}, '\n'));
|
||||
}
|
||||
setFinished();
|
||||
}
|
||||
|
Reference in New Issue
Block a user