diff options
author | Andrew Knight <andrew.knight@digia.com> | 2014-02-05 16:50:44 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-10 12:49:06 +0100 |
commit | 143d591aab7a2d244913e9d13f079de05eb7a65c (patch) | |
tree | c6bc940e90228e53b60cae50e80e2e9fb5df3ba4 /src/corelib/thread/qthread_win.cpp | |
parent | a80253ae4c2ea52a8ffb77e62648374b6fc650a8 (diff) |
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 <oliver.wolff@digia.com>
Diffstat (limited to 'src/corelib/thread/qthread_win.cpp')
-rw-r--r-- | src/corelib/thread/qthread_win.cpp | 8 |
1 files 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; |