Commit c723f281 authored by hjk's avatar hjk Committed by David Schulz
Browse files

DeviceSupport: Move 'SpecialInterrupt' to base class



Change-Id: Ie8f02128e87744f4260b0defb50473da6d6c508d
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 712af560
......@@ -72,23 +72,11 @@ void DesktopProcessSignalOperation::interruptProcess(int pid)
}
void DesktopProcessSignalOperation::interruptProcess(const QString &filePath)
{
interruptProcess(filePath, NoSpecialInterrupt);
}
void DesktopProcessSignalOperation::interruptProcess(int pid, SpecialInterrupt specialInterrupt)
{
m_errorMessage.clear();
interruptProcessSilently(pid, specialInterrupt);
}
void DesktopProcessSignalOperation::interruptProcess(const QString &filePath,
SpecialInterrupt specialInterrupt)
{
m_errorMessage.clear();
foreach (const DeviceProcessItem &process, Internal::LocalProcessList::getLocalProcesses()) {
if (process.cmdLine == filePath)
interruptProcessSilently(process.pid, specialInterrupt);
interruptProcessSilently(process.pid);
}
emit finished(m_errorMessage);
}
......@@ -128,8 +116,7 @@ void DesktopProcessSignalOperation::killProcessSilently(int pid)
#endif // Q_OS_WIN
}
void DesktopProcessSignalOperation::interruptProcessSilently(
int pid, SpecialInterrupt specialInterrupt)
void DesktopProcessSignalOperation::interruptProcessSilently(int pid)
{
#ifdef Q_OS_WIN
/*
......@@ -174,17 +161,16 @@ GDB 32bit | Api | Api | N/A | Win32
}
bool creatorIs64Bit = Utils::winIs64BitBinary(qApp->applicationFilePath());
if (!Utils::winIs64BitSystem() ||
specialInterrupt == NoSpecialInterrupt ||
specialInterrupt == Win64Interrupt && creatorIs64Bit ||
specialInterrupt == Win32Interrupt && !creatorIs64Bit) {
m_specialInterrupt == NoSpecialInterrupt ||
m_specialInterrupt == Win64Interrupt && creatorIs64Bit ||
m_specialInterrupt == Win32Interrupt && !creatorIs64Bit) {
if (!DebugBreakProcess(inferior)) {
appendMsgCannotInterrupt(pid, tr("DebugBreakProcess failed: ")
+ Utils::winErrorMessage(GetLastError()));
}
} else if (specialInterrupt == Win32Interrupt
|| specialInterrupt == Win64Interrupt) {
} else if (m_specialInterrupt == Win32Interrupt || m_specialInterrupt == Win64Interrupt) {
QString executable = QCoreApplication::applicationDirPath();
executable += specialInterrupt == Win32Interrupt
executable += m_specialInterrupt == Win32Interrupt
? QLatin1String("/win32interrupt.exe")
: QLatin1String("/win64interrupt.exe");
if (!QFile::exists(executable)) {
......@@ -211,7 +197,6 @@ GDB 32bit | Api | Api | N/A | Win32
if (inferior != NULL)
CloseHandle(inferior);
#else
Q_UNUSED(specialInterrupt)
if (pid <= 0)
appendMsgCannotInterrupt(pid, tr("Invalid process id."));
else if (kill(pid, SIGINT))
......
......@@ -39,19 +39,15 @@ class PROJECTEXPLORER_EXPORT DesktopProcessSignalOperation : public DeviceProces
{
Q_OBJECT
public:
enum SpecialInterrupt { NoSpecialInterrupt, Win32Interrupt, Win64Interrupt };
~DesktopProcessSignalOperation() {}
void killProcess(int pid);
void killProcess(const QString &filePath);
void interruptProcess(int pid);
void interruptProcess(const QString &filePath);
void interruptProcess(int pid, SpecialInterrupt specialInterrupt);
void interruptProcess(const QString &filePath, SpecialInterrupt specialInterrupt);
private:
void killProcessSilently(int pid);
void interruptProcessSilently(int pid, SpecialInterrupt = NoSpecialInterrupt);
void interruptProcessSilently(int pid);
void appendMsgCannotKill(int pid, const QString &why);
void appendMsgCannotInterrupt(int pid, const QString &why);
......
......@@ -424,4 +424,9 @@ QString IDevice::defaultPublicKeyFilePath()
return defaultPrivateKeyFilePath() + QLatin1String(".pub");
}
DeviceProcessSignalOperation::DeviceProcessSignalOperation()
: m_specialInterrupt(NoSpecialInterrupt)
{
}
} // namespace ProjectExplorer
......@@ -59,6 +59,8 @@ class PROJECTEXPLORER_EXPORT DeviceProcessSignalOperation : public QObject
{
Q_OBJECT
public:
enum SpecialInterrupt { NoSpecialInterrupt, Win32Interrupt, Win64Interrupt };
~DeviceProcessSignalOperation() {}
typedef QSharedPointer<DeviceProcessSignalOperation> Ptr;
......@@ -67,13 +69,16 @@ public:
virtual void interruptProcess(int pid) = 0;
virtual void interruptProcess(const QString &filePath) = 0;
void setSpecialInterrupt(SpecialInterrupt si);
signals:
// If the error message is empty the operation was successful
void finished(const QString &errorMessage);
protected:
explicit DeviceProcessSignalOperation() {}
explicit DeviceProcessSignalOperation();
QString m_errorMessage;
SpecialInterrupt m_specialInterrupt;
};
class PROJECTEXPLORER_EXPORT PortsGatheringMethod
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment