diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 3b9b8871e22..77868b13a04 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -165,7 +165,21 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi QString threadName = std::exchange(thr->d_func()->objectName, {}); if (Q_LIKELY(threadName.isEmpty())) threadName = QString::fromUtf8(thr->metaObject()->className()); +#ifndef QT_WIN_SERVER_2016_COMPAT SetThreadDescription(GetCurrentThread(), reinterpret_cast(threadName.utf16())); +#else + HMODULE kernelbase = GetModuleHandleW(L"kernelbase.dll"); + if (kernelbase != NULL) { + typedef HRESULT (WINAPI *DESCFUNC)(HANDLE, PCWSTR); + + DESCFUNC setThreadDescription = + (DESCFUNC)GetProcAddress(kernelbase, "SetThreadDescription"); + if (setThreadDescription != NULL) { + setThreadDescription(GetCurrentThread(), + reinterpret_cast(threadName.utf16())); + } + } +#endif emit thr->started(QThread::QPrivateSignal()); QThread::setTerminationEnabled(true); diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index 89c186a2026..50f5f7b2c7f 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -212,9 +212,23 @@ void QWindowsUiaMainProvider::raiseNotification(QAccessibleAnnouncementEvent *ev ? NotificationProcessing_ImportantAll : NotificationProcessing_All; QBStr activityId{ QString::fromLatin1("") }; +#if !defined(Q_CC_MSVC) || !defined(QT_WIN_SERVER_2016_COMPAT) UiaRaiseNotificationEvent(provider.Get(), NotificationKind_Other, processing, message.bstr(), activityId.bstr()); +#else + HMODULE uiautomationcore = GetModuleHandleW(L"UIAutomationCore.dll"); + if (uiautomationcore != NULL) { + typedef HRESULT (WINAPI *EVENTFUNC)(IRawElementProviderSimple *, NotificationKind, + NotificationProcessing, BSTR, BSTR); + EVENTFUNC uiaRaiseNotificationEvent = + (EVENTFUNC)GetProcAddress(uiautomationcore, "UiaRaiseNotificationEvent"); + if (uiaRaiseNotificationEvent != NULL) { + uiaRaiseNotificationEvent(provider.Get(), NotificationKind_Other, processing, + message.bstr(), activityId.bstr()); + } + } +#endif } } } diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiautomation.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiautomation.cpp index 5d580a6155b..7b1dbc42f5e 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiautomation.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiautomation.cpp @@ -6,7 +6,7 @@ #include "qwindowsuiautomation.h" -#if defined(__MINGW32__) || defined(__MINGW64__) +#ifndef Q_CC_MSVC template struct winapi_func @@ -78,6 +78,6 @@ HRESULT WINAPI UiaRaiseNotificationEvent( return func.invoke(pProvider, notificationKind, notificationProcessing, displayString, activityId); } -#endif // defined(__MINGW32__) || defined(__MINGW64__) +#endif // !Q_CC_MSVC #endif // QT_CONFIG(accessibility)