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>
This commit is contained in:
parent
a80253ae4c
commit
143d591aab
@ -442,7 +442,7 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway)
|
|||||||
#ifndef Q_OS_WINRT
|
#ifndef Q_OS_WINRT
|
||||||
CloseHandle(d->handle);
|
CloseHandle(d->handle);
|
||||||
#else
|
#else
|
||||||
CloseHandle(d->handle->native_handle());
|
d->handle->detach();
|
||||||
delete d->handle;
|
delete d->handle;
|
||||||
#endif
|
#endif
|
||||||
d->handle = 0;
|
d->handle = 0;
|
||||||
@ -642,8 +642,6 @@ void QThread::terminate()
|
|||||||
TerminateThread(d->handle, 0);
|
TerminateThread(d->handle, 0);
|
||||||
#else // !Q_OS_WINRT
|
#else // !Q_OS_WINRT
|
||||||
qWarning("QThread::terminate: Terminate is not supported on WinRT");
|
qWarning("QThread::terminate: Terminate is not supported on WinRT");
|
||||||
CloseHandle(d->handle->native_handle());
|
|
||||||
d->handle = 0;
|
|
||||||
#endif // Q_OS_WINRT
|
#endif // Q_OS_WINRT
|
||||||
QThreadPrivate::finish(this, false);
|
QThreadPrivate::finish(this, false);
|
||||||
}
|
}
|
||||||
@ -683,7 +681,8 @@ bool QThread::wait(unsigned long time)
|
|||||||
}
|
}
|
||||||
#else // !Q_OS_WINRT
|
#else // !Q_OS_WINRT
|
||||||
if (d->handle->joinable()) {
|
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:
|
case WAIT_OBJECT_0:
|
||||||
ret = true;
|
ret = true;
|
||||||
d->handle->join();
|
d->handle->join();
|
||||||
@ -712,6 +711,7 @@ bool QThread::wait(unsigned long time)
|
|||||||
#ifndef Q_OS_WINRT
|
#ifndef Q_OS_WINRT
|
||||||
CloseHandle(d->handle);
|
CloseHandle(d->handle);
|
||||||
#else
|
#else
|
||||||
|
d->handle->detach();
|
||||||
delete d->handle;
|
delete d->handle;
|
||||||
#endif
|
#endif
|
||||||
d->handle = 0;
|
d->handle = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user