summaryrefslogtreecommitdiff
path: root/platform/windows/os_windows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r--platform/windows/os_windows.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index bd76db8796..d6cfd039d9 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -2309,6 +2309,8 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments,
if (r_exitcode)
*r_exitcode = ret;
+ CloseHandle(pi.pi.hProcess);
+ CloseHandle(pi.pi.hThread);
} else {
ProcessID pid = pi.pi.dwProcessId;
@@ -2322,17 +2324,15 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments,
Error OS_Windows::kill(const ProcessID &p_pid) {
- HANDLE h;
+ ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED);
- if (process_map->has(p_pid)) {
- h = (*process_map)[p_pid].pi.hProcess;
- process_map->erase(p_pid);
- } else {
+ const PROCESS_INFORMATION pi = (*process_map)[p_pid].pi;
+ process_map->erase(p_pid);
- ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED);
- };
+ const int ret = TerminateProcess(pi.hProcess, 0);
- int ret = TerminateProcess(h, 0);
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
return ret != 0 ? OK : FAILED;
};
@@ -2789,23 +2789,17 @@ bool OS_Windows::is_disable_crash_handler() const {
}
Error OS_Windows::move_to_trash(const String &p_path) {
- SHFILEOPSTRUCTA sf;
- TCHAR *from = new TCHAR[p_path.length() + 2];
- strcpy(from, p_path.utf8().get_data());
- from[p_path.length()] = 0;
- from[p_path.length() + 1] = 0;
-
+ SHFILEOPSTRUCTW sf;
sf.hwnd = hWnd;
sf.wFunc = FO_DELETE;
- sf.pFrom = from;
+ sf.pFrom = p_path.c_str();
sf.pTo = NULL;
sf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION;
sf.fAnyOperationsAborted = FALSE;
sf.hNameMappings = NULL;
sf.lpszProgressTitle = NULL;
- int ret = SHFileOperation(&sf);
- delete[] from;
+ int ret = SHFileOperationW(&sf);
if (ret) {
ERR_PRINTS("SHFileOperation error: " + itos(ret));