forked from qt-creator/qt-creator
ProjectExplorer: Introduce DeviceProcessKiller
It will be much easier to integrate it into TaskTree, comparing to hierarchical DeviceProcessSignalOperation. Change-Id: I6bc9580a3d88d7bfd01e641b09094c6fa8fb94d3 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
#include "idevice.h"
|
#include "idevice.h"
|
||||||
|
|
||||||
#include "sshparameters.h"
|
#include "devicemanager.h"
|
||||||
|
|
||||||
#include "deviceprocesslist.h"
|
#include "deviceprocesslist.h"
|
||||||
#include "idevicefactory.h"
|
#include "idevicefactory.h"
|
||||||
|
#include "sshparameters.h"
|
||||||
|
|
||||||
#include "../kit.h"
|
#include "../kit.h"
|
||||||
#include "../kitinformation.h"
|
#include "../kitinformation.h"
|
||||||
@@ -654,4 +654,33 @@ DeviceProcessSignalOperation::DeviceProcessSignalOperation() = default;
|
|||||||
|
|
||||||
DeviceEnvironmentFetcher::DeviceEnvironmentFetcher() = default;
|
DeviceEnvironmentFetcher::DeviceEnvironmentFetcher() = default;
|
||||||
|
|
||||||
|
void DeviceProcessKiller::start()
|
||||||
|
{
|
||||||
|
m_signalOperation.reset();
|
||||||
|
m_errorString.clear();
|
||||||
|
|
||||||
|
const IDevice::ConstPtr device = DeviceManager::deviceForPath(m_processPath);
|
||||||
|
if (!device) {
|
||||||
|
m_errorString = tr("No device for given path: \"%1\".").arg(m_processPath.toUserOutput());
|
||||||
|
emit done(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_signalOperation = device->signalOperation();
|
||||||
|
if (!m_signalOperation) {
|
||||||
|
m_errorString = tr("Device for path \"%1\" does not support killing processes.")
|
||||||
|
.arg(m_processPath.toUserOutput());
|
||||||
|
emit done(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(m_signalOperation.get(), &DeviceProcessSignalOperation::finished,
|
||||||
|
this, [this](const QString &errorMessage) {
|
||||||
|
m_errorString = errorMessage;
|
||||||
|
emit done(m_errorString.isEmpty());
|
||||||
|
});
|
||||||
|
|
||||||
|
m_signalOperation->killProcess(m_processPath.path());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -257,7 +257,6 @@ private:
|
|||||||
friend class DeviceManager;
|
friend class DeviceManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT DeviceTester : public QObject
|
class PROJECTEXPLORER_EXPORT DeviceTester : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -277,4 +276,22 @@ protected:
|
|||||||
explicit DeviceTester(QObject *parent = nullptr);
|
explicit DeviceTester(QObject *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PROJECTEXPLORER_EXPORT DeviceProcessKiller : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setProcessPath(const Utils::FilePath &path) { m_processPath = path; }
|
||||||
|
void start();
|
||||||
|
QString errorString() const { return m_errorString; }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void done(bool success);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utils::FilePath m_processPath;
|
||||||
|
DeviceProcessSignalOperation::Ptr m_signalOperation;
|
||||||
|
QString m_errorString;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
Reference in New Issue
Block a user