Commit 9ffe0310 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by hjk
Browse files

Fix error handling when killing Windows processes.



Similar to Unix.

Change-Id: I967da0eb461e63505e4b47b5fcf6de0df6256e94
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 5a895d4f
......@@ -126,17 +126,18 @@ void LocalProcessList::doKillProcess(const DeviceProcess &process)
const DWORD rights = PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION
|PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ
|PROCESS_DUP_HANDLE|PROCESS_TERMINATE|PROCESS_CREATE_THREAD|PROCESS_SUSPEND_RESUME;
const HANDLE handle = OpenProcess(rights, FALSE, process.pid);
if (!handle) {
qWarning("Cannot open process %d: %s" , process.pid,
qPrintable(Utils::winErrorMessage(GetLastError())));
return;
}
if (!TerminateProcess(handle, UINT(-1))) {
qWarning("Cannot terminate process %d: %s" , process.pid,
qPrintable(Utils::winErrorMessage(GetLastError())));
m_error.clear();
if (const HANDLE handle = OpenProcess(rights, FALSE, process.pid)) {
if (!TerminateProcess(handle, UINT(-1))) {
m_error = tr("Cannot terminate process %1: %2").
arg(process.pid).arg(Utils::winErrorMessage(GetLastError()));
}
CloseHandle(handle);
} else {
m_error = tr("Cannot open process %1: %2").
arg(process.pid).arg(Utils::winErrorMessage(GetLastError()));
}
CloseHandle(handle);
QTimer::singleShot(0, this, SLOT(reportDelayedKillStatus()));
}
#endif //Q_OS_WIN
......@@ -255,13 +256,6 @@ void LocalProcessList::doKillProcess(const DeviceProcess &process)
QTimer::singleShot(0, this, SLOT(reportDelayedKillStatus()));
}
void LocalProcessList::reportDelayedKillStatus()
{
if (m_error.isEmpty())
reportProcessKilled();
else
reportError(m_error);
}
#endif // QT_OS_UNIX
Qt::ItemFlags LocalProcessList::flags(const QModelIndex &index) const
......@@ -282,5 +276,13 @@ void LocalProcessList::doUpdate()
QTimer::singleShot(0, this, SLOT(handleUpdate()));
}
void LocalProcessList::reportDelayedKillStatus()
{
if (m_error.isEmpty())
reportProcessKilled();
else
reportError(m_error);
}
} // namespace Internal
} // namespace RemoteLinux
......@@ -57,15 +57,11 @@ private:
private slots:
void handleUpdate();
#ifdef Q_OS_UNIX
void reportDelayedKillStatus();
#endif
private:
const qint64 m_myPid;
#ifdef Q_OS_UNIX
QString m_error;
#endif
};
} // namespace Internal
......
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