diff options
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qmutex_win.cpp | 4 | ||||
-rw-r--r-- | src/corelib/thread/qthread_win.cpp | 44 | ||||
-rw-r--r-- | src/corelib/thread/qwaitcondition_win.cpp | 5 |
3 files changed, 21 insertions, 32 deletions
diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp index acb0f9dc61..3c314a4c0c 100644 --- a/src/corelib/thread/qmutex_win.cpp +++ b/src/corelib/thread/qmutex_win.cpp @@ -61,11 +61,7 @@ QMutexPrivate::~QMutexPrivate() bool QMutexPrivate::wait(int timeout) { -#ifndef Q_OS_WINCE return (WaitForSingleObjectEx(event, timeout < 0 ? INFINITE : timeout, FALSE) == WAIT_OBJECT_0); -#else - return (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0); -#endif } void QMutexPrivate::wakeUp() Q_DECL_NOTHROW diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index ef1799a021..a14c193bad 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -55,15 +55,10 @@ #include <qt_windows.h> #ifndef Q_OS_WINRT -#ifndef Q_OS_WINCE -#ifndef _MT -#define _MT -#endif // _MT -#include <process.h> -#else // !Q_OS_WINCE -#include "qfunctions_wince.h" -#endif // Q_OS_WINCE -#else // !Q_OS_WINRT +# ifndef _MT +# define _MT +# endif // _MT +# include <process.h> #endif // Q_OS_WINRT #ifndef QT_NO_THREAD @@ -150,7 +145,6 @@ QThreadData *QThreadData::current(bool createIfNecessary) // WinRT API? } else { HANDLE realHandle = INVALID_HANDLE_VALUE; -#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600)) DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), @@ -158,9 +152,6 @@ QThreadData *QThreadData::current(bool createIfNecessary) 0, FALSE, DUPLICATE_SAME_ACCESS); -#else - realHandle = reinterpret_cast<HANDLE>(GetCurrentThreadId()); -#endif qt_watch_adopted_thread(realHandle, threadData->thread); } } @@ -190,9 +181,7 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread) QMutexLocker lock(&qt_adopted_thread_watcher_mutex); if (GetCurrentThreadId() == qt_adopted_thread_watcher_id) { -#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600)) CloseHandle(adoptedThreadHandle); -#endif return; } @@ -291,9 +280,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID) data->deref(); QMutexLocker lock(&qt_adopted_thread_watcher_mutex); -#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600)) CloseHandle(qt_adopted_thread_handles.at(handleIndex)); -#endif qt_adopted_thread_handles.remove(handleIndex); qt_adopted_qthreads.remove(qthreadIndex); } @@ -306,7 +293,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID) return 0; } -#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT) #ifndef Q_OS_WIN64 # define ULONG_PTR DWORD @@ -336,7 +323,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName) { } } -#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINCE && !Q_OS_WINRT +#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINRT /************************************************************************** ** QThreadPrivate @@ -378,7 +365,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi else createEventDispatcher(data); -#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT) // sets the name of the current thread. QByteArray objectName = thr->objectName().toLocal8Bit(); qt_set_thread_name((HANDLE)-1, @@ -453,7 +440,7 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW void QThread::yieldCurrentThread() { -#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if !defined(Q_OS_WINRT) SwitchToThread(); #else ::Sleep(0); @@ -495,7 +482,6 @@ void QThread::start(Priority priority) d->returnCode = 0; d->interruptionRequested = false; -#ifndef Q_OS_WINRT /* NOTE: we create the thread in the suspended state, set the priority and then resume the thread. @@ -506,9 +492,21 @@ void QThread::start(Priority priority) less than NormalPriority), but the newly created thread preempts its 'parent' and runs at normal priority. */ +#if defined(Q_CC_MSVC) && !defined(_DLL) // && !defined(Q_OS_WINRT) +# ifdef Q_OS_WINRT + // If you wish to accept the memory leaks, uncomment the part above. + // See: + // https://support.microsoft.com/en-us/kb/104641 + // https://msdn.microsoft.com/en-us/library/kdzttdcb.aspx +# error "Microsoft documentation says this combination leaks memory every time a thread is started. " \ + "Please change your build back to -MD/-MDd or, if you understand this issue and want to continue, " \ + "edit this source file." +# endif + // MSVC -MT or -MTd build d->handle = (Qt::HANDLE) _beginthreadex(NULL, d->stackSize, QThreadPrivate::start, this, CREATE_SUSPENDED, &(d->id)); -#else // !Q_OS_WINRT +#else + // MSVC -MD or -MDd or MinGW build d->handle = (Qt::HANDLE) CreateThread(NULL, d->stackSize, (LPTHREAD_START_ROUTINE)QThreadPrivate::start, this, CREATE_SUSPENDED, reinterpret_cast<LPDWORD>(&d->id)); #endif // Q_OS_WINRT diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp index a95ca0b8fd..e6610f18c8 100644 --- a/src/corelib/thread/qwaitcondition_win.cpp +++ b/src/corelib/thread/qwaitcondition_win.cpp @@ -115,12 +115,7 @@ bool QWaitConditionPrivate::wait(QWaitConditionEvent *wce, unsigned long time) { // wait for the event bool ret = false; -#ifndef Q_OS_WINCE switch (WaitForSingleObjectEx(wce->event, time, FALSE)) { -#else - switch (WaitForSingleObject(wce->event, time)) { -#endif - default: break; case WAIT_OBJECT_0: |