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