From 143d591aab7a2d244913e9d13f079de05eb7a65c Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Wed, 5 Feb 2014 16:50:44 +0200 Subject: WinRT: Fix use of std::thread in QThread Don't delete the thread object without detaching it, use detach() instead of CloseHandle(), and avoid a double-delete. Change-Id: Ia169a96fb32805e06abe099c3c35e97ce485f088 Reviewed-by: Oliver Wolff --- src/corelib/thread/qthread_win.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 03c5b943d6..db5c13157c 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -442,7 +442,7 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway) #ifndef Q_OS_WINRT CloseHandle(d->handle); #else - CloseHandle(d->handle->native_handle()); + d->handle->detach(); delete d->handle; #endif d->handle = 0; @@ -642,8 +642,6 @@ void QThread::terminate() TerminateThread(d->handle, 0); #else // !Q_OS_WINRT qWarning("QThread::terminate: Terminate is not supported on WinRT"); - CloseHandle(d->handle->native_handle()); - d->handle = 0; #endif // Q_OS_WINRT QThreadPrivate::finish(this, false); } @@ -683,7 +681,8 @@ bool QThread::wait(unsigned long time) } #else // !Q_OS_WINRT if (d->handle->joinable()) { - switch (WaitForSingleObjectEx(d->handle->native_handle(), time, FALSE)) { + HANDLE handle = d->handle->native_handle(); + switch (WaitForSingleObjectEx(handle, time, FALSE)) { case WAIT_OBJECT_0: ret = true; d->handle->join(); @@ -712,6 +711,7 @@ bool QThread::wait(unsigned long time) #ifndef Q_OS_WINRT CloseHandle(d->handle); #else + d->handle->detach(); delete d->handle; #endif d->handle = 0; -- cgit v1.2.3