summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2020-06-05 09:24:37 +0200
committerLiang Qi <liang.qi@qt.io>2020-06-06 20:25:49 +0200
commit45b0f1be686cfba8dcecb9be5c875cae59c69276 (patch)
tree363dfd46575d147206267d854ce14747157f432e /src/corelib/kernel
parentaa81b90738ce9faee5e433617c8bd243cb238729 (diff)
Remove winrt
Macros and the await helper function from qfunctions_winrt(_p).h are needed in other Qt modules which use UWP APIs on desktop windows. Task-number: QTBUG-84434 Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/kernel.pri28
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp38
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h2
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp42
-rw-r--r--src/corelib/kernel/qcorecmdlineargs_p.h12
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt.cpp656
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt_p.h113
-rw-r--r--src/corelib/kernel/qfunctions_fake_env_p.h130
-rw-r--r--src/corelib/kernel/qfunctions_p.h2
-rw-r--r--src/corelib/kernel/qfunctions_winrt.cpp58
-rw-r--r--src/corelib/kernel/qfunctions_winrt_p.h (renamed from src/corelib/kernel/qfunctions_winrt.h)110
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp13
-rw-r--r--src/corelib/kernel/qsystemerror.cpp12
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp6
-rw-r--r--src/corelib/kernel/qtestsupport_core.cpp4
-rw-r--r--src/corelib/kernel/qwineventnotifier.cpp21
16 files changed, 41 insertions, 1206 deletions
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 76609894ba..fc48ef430e 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -88,27 +88,15 @@ win32 {
kernel/qsystemsemaphore_win.cpp
HEADERS += \
kernel/qwineventnotifier.h \
- kernel/qwineventnotifier_p.h
-
- winrt {
- SOURCES += kernel/qeventdispatcher_winrt.cpp
- HEADERS += kernel/qeventdispatcher_winrt_p.h
- } else {
- SOURCES += kernel/qeventdispatcher_win.cpp \
- kernel/qwinregistry.cpp
- HEADERS += kernel/qeventdispatcher_win_p.h \
- kernel/qwinregistry_p.h
- }
-
- !winrt: LIBS_PRIVATE += -lversion
-}
+ kernel/qwineventnotifier_p.h \
+ kernel/qfunctions_winrt_p.h
-winrt {
- SOURCES += \
- kernel/qfunctions_winrt.cpp
- HEADERS += \
- kernel/qfunctions_fake_env_p.h \
- kernel/qfunctions_winrt.h
+ SOURCES += kernel/qeventdispatcher_win.cpp \
+ kernel/qwinregistry.cpp
+ HEADERS += kernel/qeventdispatcher_win_p.h \
+ kernel/qwinregistry_p.h
+
+ LIBS_PRIVATE += -lversion
}
mac {
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 43f641244b..a3414b3edc 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -87,16 +87,7 @@
# include "qeventdispatcher_unix_p.h"
#endif
#ifdef Q_OS_WIN
-# ifdef Q_OS_WINRT
-# include "qeventdispatcher_winrt_p.h"
-# include "qfunctions_winrt.h"
-# include <wrl.h>
-# include <Windows.ApplicationModel.core.h>
- using namespace ABI::Windows::ApplicationModel::Core;
- using namespace Microsoft::WRL;
-# else
-# include "qeventdispatcher_win_p.h"
-# endif
+#include "qeventdispatcher_win_p.h"
#endif
#endif // QT_NO_QOBJECT
@@ -397,7 +388,7 @@ Q_GLOBAL_STATIC(QCoreApplicationData, coreappdata)
static bool quitLockRefEnabled = true;
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN)
// Check whether the command line arguments match those passed to main()
// by comparing to the global __argv/__argc (MS extension).
// Deep comparison is required since argv/argc is rebuilt by WinMain for
@@ -423,7 +414,7 @@ static inline bool contains(int argc, char **argv, const char *needle)
}
return false;
}
-#endif // Q_OS_WIN && !Q_OS_WINRT
+#endif // Q_OS_WIN
QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint flags)
:
@@ -432,7 +423,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint
#endif
argc(aargc)
, argv(aargv)
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN)
, origArgc(0)
, origArgv(nullptr)
#endif
@@ -451,13 +442,13 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint
argc = 0;
argv = const_cast<char **>(&empty);
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN)
if (!isArgvModified(argc, argv)) {
origArgc = argc;
origArgv = new char *[argc];
std::copy(argv, argv + argc, QT_MAKE_CHECKED_ARRAY_ITERATOR(origArgv, argc));
}
-#endif // Q_OS_WIN && !Q_OS_WINRT
+#endif // Q_OS_WIN
#ifndef QT_NO_QOBJECT
QCoreApplicationPrivate::is_app_closing = false;
@@ -467,10 +458,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint
qFatal("FATAL: The application binary appears to be running setuid, this is a security hole.");
# endif // Q_OS_UNIX
-#ifdef Q_OS_WINRT
- QThreadData::setMainThread();
-#endif
-
QThread *cur = QThread::currentThread(); // note: this may end up setting theMainThread!
if (cur != theMainThread.loadAcquire())
qWarning("WARNING: QApplication was not created in the main() thread.");
@@ -482,7 +469,7 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate()
#ifndef QT_NO_QOBJECT
cleanupThreadData();
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN)
delete [] origArgv;
#endif
QCoreApplicationPrivate::clearApplicationFilePath();
@@ -570,10 +557,6 @@ void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths()
coreappdata()->app_libpaths.reset(app_libpaths = new QStringList);
QString app_location = QCoreApplication::applicationFilePath();
app_location.truncate(app_location.lastIndexOf(QLatin1Char('/')));
-#ifdef Q_OS_WINRT
- if (app_location.isEmpty())
- app_location.append(QLatin1Char('/'));
-#endif
app_location = QDir(app_location).canonicalPath();
if (QFile::exists(app_location) && !app_libpaths->contains(app_location))
app_libpaths->append(app_location);
@@ -2466,7 +2449,7 @@ QStringList QCoreApplication::arguments()
char ** const av = self->d_func()->argv;
list.reserve(ac);
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN)
// On Windows, it is possible to pass Unicode arguments on
// the command line. To restore those, we split the command line
// and filter out arguments that were deleted by derived application
@@ -2483,7 +2466,7 @@ QStringList QCoreApplication::arguments()
}
return list;
} // Fall back to rebuilding from argv/argc when a modified argv was passed.
-#endif // defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+#endif // defined(Q_OS_WIN)
for (int a = 0; a < ac; ++a) {
list << QString::fromLocal8Bit(av[a]);
@@ -2623,9 +2606,6 @@ QString QCoreApplication::applicationName()
\li Windows (classic desktop)
\li PRODUCTVERSION parameter of the VERSIONINFO resource
\row
- \li Universal Windows Platform
- \li version attribute of the application package manifest
- \row
\li macOS, iOS, tvOS, watchOS
\li CFBundleVersion property of the information property list
\row
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 9d2fde619c..cb3a5a8a4f 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -154,7 +154,7 @@ public:
int &argc;
char **argv;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN)
int origArgc;
char **origArgv; // store unmodified arguments for QCoreApplication::arguments()
#endif
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 824c0535ed..a0fbf97838 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -53,16 +53,6 @@
#include <ctype.h>
#include <qt_windows.h>
-#ifdef Q_OS_WINRT
-#include <qfunctions_winrt.h>
-#include <wrl.h>
-#include <Windows.ApplicationModel.core.h>
-#include <windows.foundation.h>
-using namespace ABI::Windows::ApplicationModel;
-using namespace Microsoft::WRL;
-using namespace Microsoft::WRL::Wrappers;
-#endif
-
QT_BEGIN_NAMESPACE
Q_CORE_EXPORT QString qAppFileName() // get application file name
@@ -105,33 +95,6 @@ QString QCoreApplicationPrivate::appVersion() const
{
QString applicationVersion;
#ifndef QT_BOOTSTRAPPED
-# ifdef Q_OS_WINRT
- HRESULT hr;
-
- ComPtr<IPackageStatics> packageFactory;
- hr = RoGetActivationFactory(
- HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Package).Get(),
- IID_PPV_ARGS(&packageFactory));
- RETURN_IF_FAILED("Failed to create package instance", return QString());
-
- ComPtr<IPackage> package;
- packageFactory->get_Current(&package);
- RETURN_IF_FAILED("Failed to get current application package", return QString());
-
- ComPtr<IPackageId> packageId;
- package->get_Id(&packageId);
- RETURN_IF_FAILED("Failed to get current application package ID", return QString());
-
- PackageVersion version;
- packageId->get_Version(&version);
- RETURN_IF_FAILED("Failed to get current application package version", return QString());
-
- applicationVersion = QStringLiteral("%1.%2.%3.%4")
- .arg(version.Major)
- .arg(version.Minor)
- .arg(version.Build)
- .arg(version.Revision);
-# else
const QString appFileName = qAppFileName();
QVarLengthArray<wchar_t> buffer(appFileName.size() + 1);
buffer[appFileName.toWCharArray(buffer.data())] = 0;
@@ -154,13 +117,10 @@ QString QCoreApplicationPrivate::appVersion() const
}
}
}
-# endif
#endif
return applicationVersion;
}
-#ifndef Q_OS_WINRT
-
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle
{
@@ -913,8 +873,6 @@ QDebug operator<<(QDebug dbg, const MSG &msg)
#endif // QT_NO_QOBJECT
-#endif // !defined(Q_OS_WINRT)
-
#ifndef QT_NO_QOBJECT
void QCoreApplicationPrivate::removePostedTimerEvent(QObject *object, int timerId)
{
diff --git a/src/corelib/kernel/qcorecmdlineargs_p.h b/src/corelib/kernel/qcorecmdlineargs_p.h
index 33445a1625..b9f1ef6317 100644
--- a/src/corelib/kernel/qcorecmdlineargs_p.h
+++ b/src/corelib/kernel/qcorecmdlineargs_p.h
@@ -82,17 +82,7 @@ static inline QStringList qWinCmdArgs(const QString &cmdLine)
return result;
}
-#elif defined(Q_OS_WINRT) // Q_OS_WIN32
-
-static inline QStringList qCmdLineArgs(int argc, char *argv[])
-{
- QStringList args;
- for (int i = 0; i != argc; ++i)
- args += QString::fromLocal8Bit(argv[i]);
- return args;
-}
-
-#endif // Q_OS_WINRT
+#endif // Q_OS_WIN32
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp
deleted file mode 100644
index f7a1f969a8..0000000000
--- a/src/corelib/kernel/qeventdispatcher_winrt.cpp
+++ /dev/null
@@ -1,656 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeventdispatcher_winrt_p.h"
-
-#include <QtCore/QCoreApplication>
-#include <QtCore/QThread>
-#include <QtCore/QHash>
-#include <QtCore/QMutex>
-#include <QtCore/QSemaphore>
-#include <QtCore/qfunctions_winrt.h>
-#include <private/qabstracteventdispatcher_p.h>
-#include <private/qcoreapplication_p.h>
-
-#include <functional>
-#include <memory>
-
-#include <wrl.h>
-#include <windows.foundation.h>
-#include <windows.system.threading.h>
-#include <windows.ui.core.h>
-#include <windows.applicationmodel.core.h>
-using namespace Microsoft::WRL;
-using namespace Microsoft::WRL::Wrappers;
-using namespace ABI::Windows::System::Threading;
-using namespace ABI::Windows::Foundation;
-using namespace ABI::Windows::Foundation::Collections;
-using namespace ABI::Windows::UI::Core;
-using namespace ABI::Windows::ApplicationModel::Core;
-
-QT_BEGIN_NAMESPACE
-
-#define INTERRUPT_HANDLE 0
-#define INVALID_TIMER_ID -1
-
-struct WinRTTimerInfo : public QAbstractEventDispatcher::TimerInfo {
- WinRTTimerInfo(int timerId = INVALID_TIMER_ID, int interval = 0, Qt::TimerType timerType = Qt::CoarseTimer,
- QObject *obj = 0, quint64 tt = 0) :
- QAbstractEventDispatcher::TimerInfo(timerId, interval, timerType),
- inEvent(false), object(obj), targetTime(tt)
- {
- }
-
- bool inEvent;
- QObject *object;
- quint64 targetTime;
-};
-
-class AgileDispatchedHandler : public RuntimeClass<RuntimeClassFlags<WinRtClassicComMix>, IDispatchedHandler, IAgileObject>
-{
-public:
- AgileDispatchedHandler(const std::function<HRESULT()> &delegate)
- : delegate(delegate)
- {
- }
-
- HRESULT __stdcall Invoke()
- {
- return delegate();
- }
-
-private:
- std::function<HRESULT()> delegate;
-};
-
-class QWorkHandler : public IWorkItemHandler
-{
-public:
- QWorkHandler(const std::function<HRESULT()> &delegate)
- : m_delegate(delegate)
- {
- }
-
- STDMETHODIMP Invoke(ABI::Windows::Foundation::IAsyncAction *operation)
- {
- HRESULT res = m_delegate();
- Q_UNUSED(operation);
- return res;
- }
-
- STDMETHODIMP QueryInterface(REFIID riid, void FAR* FAR* ppvObj)
- {
- if (riid == IID_IUnknown || riid == IID_IWorkItemHandler) {
- *ppvObj = this;
- AddRef();
- return NOERROR;
- }
- *ppvObj = NULL;
- return ResultFromScode(E_NOINTERFACE);
- }
-
- STDMETHODIMP_(ULONG) AddRef(void)
- {
- return ++m_refs;
- }
-
- STDMETHODIMP_(ULONG) Release(void)
- {
- if (--m_refs == 0) {
- delete this;
- return 0;
- }
- return m_refs;
- }
-
-private:
- std::function<HRESULT()> m_delegate;
- ULONG m_refs{0};
-};
-
-class QEventDispatcherWinRTPrivate : public QAbstractEventDispatcherPrivate
-{
- Q_DECLARE_PUBLIC(QEventDispatcherWinRT)
-
-public:
- QEventDispatcherWinRTPrivate();
- ~QEventDispatcherWinRTPrivate();
-
-private:
- QHash<int, QObject *> timerIdToObject;
- QVector<WinRTTimerInfo> timerInfos;
- mutable QMutex timerInfoLock;
- QHash<HANDLE, int> timerHandleToId;
- QHash<int, HANDLE> timerIdToHandle;
- QHash<int, HANDLE> timerIdToCancelHandle;
-
- void addTimer(int id, int interval, Qt::TimerType type, QObject *obj,
- HANDLE handle, HANDLE cancelHandle)
- {
- // Zero timer events do not need these handles.
- if (interval > 0) {
- timerHandleToId.insert(handle, id);
- timerIdToHandle.insert(id, handle);
- timerIdToCancelHandle.insert(id, cancelHandle);
- }
-
- const quint64 targetTime = qt_msectime() + interval;
- const WinRTTimerInfo info(id, interval, type, obj, targetTime);
- QMutexLocker locker(&timerInfoLock);
- if (id >= timerInfos.size())
- timerInfos.resize(id + 1);
- timerInfos[id] = info;
- timerIdToObject.insert(id, obj);
- }
-
- bool removeTimer(int id)
- {
- QMutexLocker locker(&timerInfoLock);
- if (id >= timerInfos.size())
- return false;
-
- WinRTTimerInfo &info = timerInfos[id];
- if (info.timerId == INVALID_TIMER_ID)
- return false;
-
- if (info.interval > 0 && (!timerIdToHandle.contains(id) || !timerIdToCancelHandle.contains(id)))
- return false;
-
- info.timerId = INVALID_TIMER_ID;
-
- // Remove invalid timerinfos from the vector's end, if the timer with the highest id was removed
- int lastTimer = timerInfos.size() - 1;
- while (lastTimer >= 0 && timerInfos.at(lastTimer).timerId == INVALID_TIMER_ID)
- --lastTimer;
- if (lastTimer >= 0 && lastTimer != timerInfos.size() - 1)
- timerInfos.resize(lastTimer + 1);
- timerIdToObject.remove(id);
- // ... remove handle from all lists
- if (info.interval > 0) {
- HANDLE handle = timerIdToHandle.take(id);
- timerHandleToId.remove(handle);
- SetEvent(timerIdToCancelHandle.take(id));
- }
- return true;
- }
-};
-
-QEventDispatcherWinRT::QEventDispatcherWinRT(QObject *parent)
- : QAbstractEventDispatcher(*new QEventDispatcherWinRTPrivate, parent)
-{
-}
-
-QEventDispatcherWinRT::QEventDispatcherWinRT(QEventDispatcherWinRTPrivate &dd, QObject *parent)
- : QAbstractEventDispatcher(dd, parent)
-{ }
-
-QEventDispatcherWinRT::~QEventDispatcherWinRT()
-{
-}
-
-HRESULT QEventDispatcherWinRT::runOnXamlThread(const std::function<HRESULT ()> &delegate, bool waitForRun)
-{
- static __declspec(thread) ICoreDispatcher *dispatcher = nullptr;
- HRESULT hr;
- if (!dispatcher) {
- ComPtr<ICoreImmersiveApplication> application;
- hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(),
- IID_PPV_ARGS(&application));
- ComPtr<ICoreApplicationView> view;
- hr = application->get_MainView(&view);
- if (SUCCEEDED(hr) && view) {
- ComPtr<ICoreWindow> window;
- hr = view->get_CoreWindow(&window);
- Q_ASSERT_SUCCEEDED(hr);
- if (!window) {
- // In case the application is launched via activation
- // there might not be a main view (eg ShareTarget).
- // Hence iterate through the available views and try to find
- // a dispatcher in there
- ComPtr<IVectorView<CoreApplicationView*>> appViews;
- hr = application->get_Views(&appViews);
- Q_ASSERT_SUCCEEDED(hr);
- quint32 count;
- hr = appViews->get_Size(&count);
- Q_ASSERT_SUCCEEDED(hr);
- for (quint32 i = 0; i < count; ++i) {
- hr = appViews->GetAt(i, &view);
- Q_ASSERT_SUCCEEDED(hr);
- hr = view->get_CoreWindow(&window);
- Q_ASSERT_SUCCEEDED(hr);
- if (window) {
- hr = window->get_Dispatcher(&dispatcher);
- Q_ASSERT_SUCCEEDED(hr);
- if (dispatcher)
- break;
- }
- }
- } else {
- hr = window->get_Dispatcher(&dispatcher);
- Q_ASSERT_SUCCEEDED(hr);
- }
- }
- }
-
- if (Q_UNLIKELY(!dispatcher)) {
- // In case the application is launched in a way that has no UI and
- // also does not allow to create one, e.g. as a background task.
- // Features like network operations do still work, others might cause
- // errors in that case.
- ComPtr<IThreadPoolStatics> tpStatics;
- hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPool).Get(),
- IID_PPV_ARGS(&tpStatics));
- ComPtr<IAsyncAction> op;
- hr = tpStatics.Get()->RunAsync(new QWorkHandler(delegate), &op);
- if (FAILED(hr) || !waitForRun)
- return hr;
- return QWinRTFunctions::await(op);
- }
-
- boolean onXamlThread;
- hr = dispatcher->get_HasThreadAccess(&onXamlThread);
- Q_ASSERT_SUCCEEDED(hr);
- if (onXamlThread) // Already there
- return delegate();
-
- ComPtr<IAsyncAction> op;
- hr = dispatcher->RunAsync(CoreDispatcherPriority_Normal, Make<AgileDispatchedHandler>(delegate).Get(), &op);
- if (FAILED(hr) || !waitForRun)
- return hr;
- return QWinRTFunctions::await(op);
-}
-
-HRESULT QEventDispatcherWinRT::runOnMainThread(const std::function<HRESULT()> &delegate, int timeout)
-{
- if (QThread::currentThread() == QCoreApplication::instance()->thread())
- return delegate();
-
- struct State {
- QSemaphore semaphore;
- HRESULT result;
- };
-
- const auto state = std::make_shared<State>();
-
- QMetaObject::invokeMethod(QCoreApplication::instance(), [delegate, state]() {
- const QSemaphoreReleaser releaser{state->semaphore};
- state->result = delegate();
- }, nullptr);
-
- return state->semaphore.tryAcquire(1, timeout) ? state->result : E_FAIL;
-}
-
-bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags)
-{
- Q_D(QEventDispatcherWinRT);
-
- DWORD waitTime = 0;
- do {
- // Additional user events have to be handled before timer events, but the function may not
- // return yet.
- const bool userEventsSent = sendPostedEvents(flags);
-
- const QVector<HANDLE> timerHandles = d->timerIdToHandle.values().toVector();
- if (waitTime)
- emit aboutToBlock();
- bool timerEventsSent = false;
- DWORD waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, waitTime, TRUE);
- while (waitResult >= WAIT_OBJECT_0 && waitResult < WAIT_OBJECT_0 + timerHandles.count()) {
- timerEventsSent = true;
- const HANDLE handle = timerHandles.value(waitResult - WAIT_OBJECT_0);
- ResetEvent(handle);
- const int timerId = d->timerHandleToId.value(handle);
- if (timerId == INTERRUPT_HANDLE)
- break;
-
- {
- QMutexLocker locker(&d->timerInfoLock);
-
- WinRTTimerInfo &info = d->timerInfos[timerId];
- Q_ASSERT(info.timerId != INVALID_TIMER_ID);
-
- QCoreApplication::postEvent(this, new QTimerEvent(timerId));
-
- // Update timer's targetTime
- const quint64 targetTime = qt_msectime() + info.interval;
- info.targetTime = targetTime;
- }
- waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, 0, TRUE);
- }
- emit awake();
- if (timerEventsSent || userEventsSent)
- return true;
-
- // We cannot wait infinitely like on other platforms, as
- // WaitForMultipleObjectsEx might not return.
- // For instance win32 uses MsgWaitForMultipleObjects to hook
- // into the native event loop, while WinRT handles those
- // via callbacks.
- waitTime = 1;
- } while (flags & QEventLoop::WaitForMoreEvents);
- return false;
-}
-
-bool QEventDispatcherWinRT::sendPostedEvents(QEventLoop::ProcessEventsFlags flags)
-{
- Q_UNUSED(flags);
- if (hasPendingEvents()) {
- QCoreApplication::sendPostedEvents();
- return true;
- }
- return false;
-}
-
-bool QEventDispatcherWinRT::hasPendingEvents()
-{
- return qGlobalPostedEventsCount();
-}
-
-void QEventDispatcherWinRT::registerSocketNotifier(QSocketNotifier *notifier)
-{
- Q_UNUSED(notifier);
- Q_UNIMPLEMENTED();
-}
-void QEventDispatcherWinRT::unregisterSocketNotifier(QSocketNotifier *notifier)
-{
- Q_UNUSED(notifier);
- Q_UNIMPLEMENTED();
-}
-
-void QEventDispatcherWinRT::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object)
-{
- Q_UNUSED(timerType);
-
- if (timerId < 1 || interval < 0 || !object) {
-#ifndef QT_NO_DEBUG
- qWarning("QEventDispatcherWinRT::registerTimer: invalid arguments");
-#endif
- return;
- } else if (object->thread() != thread() || thread() != QThread::currentThread()) {
-#ifndef QT_NO_DEBUG
- qWarning("QEventDispatcherWinRT::registerTimer: timers cannot be started from another thread");
-#endif
- return;
- }
-
- Q_D(QEventDispatcherWinRT);
- // Don't use timer factory for zero-delay timers
- if (interval == 0u) {
- d->addTimer(timerId, interval, timerType, object, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE);
- QCoreApplication::postEvent(this, new QTimerEvent(timerId));
- return;
- }
-
- TimeSpan period;
- // TimeSpan is based on 100-nanosecond units
- period.Duration = qMax(qint64(1), qint64(interval) * 10000);
- const HANDLE handle = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, SYNCHRONIZE | EVENT_MODIFY_STATE);
- const HANDLE cancelHandle = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, SYNCHRONIZE|EVENT_MODIFY_STATE);
- HRESULT hr = runOnXamlThread([cancelHandle, handle, period]() {
- static ComPtr<IThreadPoolTimerStatics> timerFactory;
- HRESULT hr;
- if (!timerFactory) {
- hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPoolTimer).Get(),
- &timerFactory);
- Q_ASSERT_SUCCEEDED(hr);
- }
- IThreadPoolTimer *timer;
- hr = timerFactory->CreatePeriodicTimerWithCompletion(
- Callback<ITimerElapsedHandler>([handle, cancelHandle](IThreadPoolTimer *timer) {
- DWORD cancelResult = WaitForSingleObjectEx(cancelHandle, 0, TRUE);
- if (cancelResult == WAIT_OBJECT_0) {
- timer->Cancel();
- return S_OK;
- }
- if (!SetEvent(handle)) {
- Q_ASSERT_X(false, "QEventDispatcherWinRT::registerTimer",
- "SetEvent should never fail here");
- return S_OK;
- }
- return S_OK;
- }).Get(), period,
- Callback<ITimerDestroyedHandler>([handle, cancelHandle](IThreadPoolTimer *) {
- CloseHandle(handle);
- CloseHandle(cancelHandle);
- return S_OK;
- }).Get(), &timer);
- RETURN_HR_IF_FAILED("Failed to create periodic timer");
- return hr;
- }, false);
- if (FAILED(hr)) {
- CloseHandle(handle);
- CloseHandle(cancelHandle);
- return;
- }
- d->addTimer(timerId, interval, timerType, object, handle, cancelHandle);
-}
-
-bool QEventDispatcherWinRT::unregisterTimer(int timerId)
-{
- if (timerId < 1) {
-#ifndef QT_NO_DEBUG
- qWarning("QEventDispatcherWinRT::unregisterTimer: invalid argument");
-#endif
- return false;
- }
- if (thread() != QThread::currentThread()) {
-#ifndef QT_NO_DEBUG
- qWarning("QEventDispatcherWinRT::unregisterTimer: timers cannot be stopped from another thread");
-#endif
- return false;
- }
-
- // As we post all timer events internally, they have to pe removed to prevent stray events
- QCoreApplicationPrivate::removePostedTimerEvent(this, timerId);
- Q_D(QEventDispatcherWinRT);
- return d->removeTimer(timerId);
-}
-
-bool QEventDispatcherWinRT::unregisterTimers(QObject *object)
-{
- if (!object) {
-#ifndef QT_NO_DEBUG
- qWarning("QEventDispatcherWinRT::unregisterTimers: invalid argument");
-#endif
- return false;
- }
- QThread *currentThread = QThread::currentThread();
- if (object->thread() != thread() || thread() != currentThread) {
-#ifndef QT_NO_DEBUG
- qWarning("QEventDispatcherWinRT::unregisterTimers: timers cannot be stopped from another thread");
-#endif
- return false;
- }
-
- Q_D(QEventDispatcherWinRT);
- const auto timerIds = d->timerIdToObject.keys(); // ### FIXME: iterate over hash directly? But unregisterTimer() modifies the hash!
- for (int id : timerIds) {
- if (d->timerIdToObject.value(id) == object)
- unregisterTimer(id);
- }
-
- return true;
-}
-
-QList<QAbstractEventDispatcher::TimerInfo> QEventDispatcherWinRT::registeredTimers(QObject *object) const
-{
- if (!object) {
-#ifndef QT_NO_DEBUG
- qWarning("QEventDispatcherWinRT:registeredTimers: invalid argument");
-#endif
- return QList<TimerInfo>();
- }
-
- Q_D(const QEventDispatcherWinRT);
- QMutexLocker locker(&d->timerInfoLock);
- QList<TimerInfo> timerInfos;
- for (const WinRTTimerInfo &info : d->timerInfos) {
- if (info.object == object && info.timerId != INVALID_TIMER_ID)
- timerInfos.append(info);
- }
- return timerInfos;
-}
-
-bool QEventDispatcherWinRT::registerEventNotifier(QWinEventNotifier *notifier)
-{
- Q_UNUSED(notifier);
- Q_UNIMPLEMENTED();
- return false;
-}
-
-void QEventDispatcherWinRT::unregisterEventNotifier(QWinEventNotifier *notifier)
-{
- Q_UNUSED(notifier);
- Q_UNIMPLEMENTED();
-}
-
-int QEventDispatcherWinRT::remainingTime(int timerId)
-{
- if (timerId < 1) {
-#ifndef QT_NO_DEBUG
- qWarning("QEventDispatcherWinRT::remainingTime: invalid argument");
-#endif
- return -1;
- }
-
- Q_D(QEventDispatcherWinRT);
- QMutexLocker locker(&d->timerInfoLock);
- const WinRTTimerInfo timerInfo = d->timerInfos.at(timerId);
- if (timerInfo.timerId == INVALID_TIMER_ID) {
-#ifndef QT_NO_DEBUG
- qWarning("QEventDispatcherWinRT::remainingTime: timer id %d not found", timerId);
-#endif
- return -1;
- }
-
- const quint64 currentTime = qt_msectime();
- if (currentTime < timerInfo.targetTime) {
- // time to wait
- return timerInfo.targetTime - currentTime;
- } else {
- return 0;
- }
-
- return -1;
-}
-
-void QEventDispatcherWinRT::wakeUp()
-{
-}
-
-void QEventDispatcherWinRT::interrupt()
-{
- Q_D(QEventDispatcherWinRT);
- SetEvent(d->timerIdToHandle.value(INTERRUPT_HANDLE));
-}
-
-void QEventDispatcherWinRT::flush()
-{
-}
-
-void QEventDispatcherWinRT::startingUp()
-{
-}
-
-void QEventDispatcherWinRT::closingDown()
-{
-}
-
-bool QEventDispatcherWinRT::event(QEvent *e)
-{
- Q_D(QEventDispatcherWinRT);
- switch (e->type()) {
- case QEvent::Timer: {
- QTimerEvent *timerEvent = static_cast<QTimerEvent *>(e);
- const int id = timerEvent->timerId();
-
- QMutexLocker locker(&d->timerInfoLock);
-
- Q_ASSERT(id < d->timerInfos.size());
- WinRTTimerInfo &info = d->timerInfos[id];
- Q_ASSERT(info.timerId != INVALID_TIMER_ID);
-
- if (info.inEvent) // but don't allow event to recurse
- break;
- info.inEvent = true;
-
- QObject *timerObj = d->timerIdToObject.value(id);
- locker.unlock();
-
- QTimerEvent te(id);
- QCoreApplication::sendEvent(timerObj, &te);
-
- locker.relock();
-
- // The timer might have been removed in the meanwhile. If the timer was
- // the last one in the list, id is bigger than the list's size.
- // Otherwise, the id will just be set to INVALID_TIMER_ID.
- if (id >= d->timerInfos.size() || info.timerId == INVALID_TIMER_ID)
- break;
-
- if (info.interval == 0 && info.inEvent) {
- // post the next zero timer event as long as the timer was not restarted
- QCoreApplication::postEvent(this, new QTimerEvent(id));
- }
- info.inEvent = false;
- }
- default:
- break;
- }
- return QAbstractEventDispatcher::event(e);
-}
-
-QEventDispatcherWinRTPrivate::QEventDispatcherWinRTPrivate()
-{
- const bool isGuiThread = QCoreApplication::instance() &&
- QThread::currentThread() == QCoreApplication::instance()->thread();
- CoInitializeEx(NULL, isGuiThread ? COINIT_APARTMENTTHREADED : COINIT_MULTITHREADED);
- HANDLE interruptHandle = CreateEventEx(NULL, NULL, NULL, SYNCHRONIZE|EVENT_MODIFY_STATE);
- timerIdToHandle.insert(INTERRUPT_HANDLE, interruptHandle);
- timerHandleToId.insert(interruptHandle, INTERRUPT_HANDLE);
- timerInfos.reserve(256);
-}
-
-QEventDispatcherWinRTPrivate::~QEventDispatcherWinRTPrivate()
-{
- CloseHandle(timerIdToHandle.value(INTERRUPT_HANDLE));
- CoUninitialize();
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_winrt_p.h b/src/corelib/kernel/qeventdispatcher_winrt_p.h
deleted file mode 100644
index 2672f11123..0000000000
--- a/src/corelib/kernel/qeventdispatcher_winrt_p.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef QEVENTDISPATCHER_WINRT_P_H
-#define QEVENTDISPATCHER_WINRT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/private/qglobal_p.h>
-#include "QtCore/qabstracteventdispatcher.h"
-
-#include <qt_windows.h>
-
-#include <functional>
-
-QT_BEGIN_NAMESPACE
-
-quint64 qt_msectime();
-
-class QEventDispatcherWinRTPrivate;
-
-class Q_CORE_EXPORT QEventDispatcherWinRT : public QAbstractEventDispatcher
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QEventDispatcherWinRT)
-
-public:
- explicit QEventDispatcherWinRT(QObject *parent = 0);
- ~QEventDispatcherWinRT();
-
- static HRESULT runOnXamlThread(const std::function<HRESULT()> &delegate, bool waitForRun = true);
- static HRESULT runOnMainThread(const std::function<HRESULT()> &delegate, int timeout = 100);
-
- bool processEvents(QEventLoop::ProcessEventsFlags flags);
- bool hasPendingEvents();
-
- void registerSocketNotifier(QSocketNotifier *notifier);
- void unregisterSocketNotifier(QSocketNotifier *notifier);
-
- void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object);
- bool unregisterTimer(int timerId);
- bool unregisterTimers(QObject *object);
- QList<TimerInfo> registeredTimers(QObject *object) const;
-
- int remainingTime(int timerId);
-
- bool registerEventNotifier(QWinEventNotifier *notifier);
- void unregisterEventNotifier(QWinEventNotifier *notifier);
-
- void wakeUp();
- void interrupt();
- void flush();
-
- void startingUp();
- void closingDown();
-
-protected:
- QEventDispatcherWinRT(QEventDispatcherWinRTPrivate &dd, QObject *parent = 0);
-
- virtual bool sendPostedEvents(QEventLoop::ProcessEventsFlags flags);
- bool event(QEvent *);
- int activateTimers();
-};
-
-QT_END_NAMESPACE
-
-#endif // QEVENTDISPATCHER_WINRT_P_H
diff --git a/src/corelib/kernel/qfunctions_fake_env_p.h b/src/corelib/kernel/qfunctions_fake_env_p.h
deleted file mode 100644
index 68d17ed4a1..0000000000
--- a/src/corelib/kernel/qfunctions_fake_env_p.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFUNCTIONS_FAKE_ENV_P_H
-#define QFUNCTIONS_FAKE_ENV_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qbytearray.h"
-#include "qvector.h"
-
-QT_BEGIN_NAMESPACE
-
-// Environment ------------------------------------------------------
-struct Variable {
- Variable() { }
-
- Variable(const QByteArray &name, const QByteArray &value)
- : name(name), value(value) { }
-
- QByteArray name;
- QByteArray value;
-};
-
-Q_DECLARE_TYPEINFO(Variable, Q_MOVABLE_TYPE);
-
-struct NameEquals {
- typedef bool result_type;
- const char *name;
- explicit NameEquals(const char *name) noexcept : name(name) {}
- result_type operator()(const Variable &other) const noexcept
- { return qstrcmp(other.name, name) == 0; }
-};
-
-#ifndef Q_CLANG_QDOC
-Q_GLOBAL_STATIC(QVector<Variable>, qt_app_environment)
-#endif
-
-errno_t qt_fake_getenv_s(size_t *sizeNeeded, char *buffer, size_t bufferSize, const char *varName)
-{
- if (!sizeNeeded)
- return EINVAL;
-
- QVector<Variable>::const_iterator end = qt_app_environment->constEnd();
- QVector<Variable>::const_iterator iterator = std::find_if(qt_app_environment->constBegin(),
- end,
- NameEquals(varName));
- if (iterator == end) {
- if (buffer)
- buffer[0] = '\0';
- return ENOENT;
- }
-
- const int size = iterator->value.size() + 1;
- if (bufferSize < size_t(size)) {
- *sizeNeeded = size;
- return ERANGE;
- }
-
- qstrcpy(buffer, iterator->value.constData());
- return 0;
-}
-
-errno_t qt_fake__putenv_s(const char *varName, const char *value)
-{
- QVector<Variable>::iterator end = qt_app_environment->end();
- QVector<Variable>::iterator iterator = std::find_if(qt_app_environment->begin(),
- end,
- NameEquals(varName));
- if (!value || !*value) {
- if (iterator != end)
- qt_app_environment->erase(iterator);
- } else {
- if (iterator == end)
- qt_app_environment->append(Variable(varName, value));
- else
- iterator->value = value;
- }
-
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QFUNCTIONS_FAKE_ENV_P_H
diff --git a/src/corelib/kernel/qfunctions_p.h b/src/corelib/kernel/qfunctions_p.h
index 715c553dc5..6744146aa8 100644
--- a/src/corelib/kernel/qfunctions_p.h
+++ b/src/corelib/kernel/qfunctions_p.h
@@ -57,8 +57,6 @@
# include "QtCore/qfunctions_vxworks.h"
#elif defined(Q_OS_NACL)
# include "QtCore/qfunctions_nacl.h"
-#elif defined(Q_OS_WINRT)
-# include "QtCore/qfunctions_winrt.h"
#endif
#endif
diff --git a/src/corelib/kernel/qfunctions_winrt.cpp b/src/corelib/kernel/qfunctions_winrt.cpp
deleted file mode 100644
index 6b7e79806f..0000000000
--- a/src/corelib/kernel/qfunctions_winrt.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfunctions_winrt.h"
-
-#ifdef Q_OS_WINRT
-
-#include "qfunctions_fake_env_p.h"
-
-QT_BEGIN_NAMESPACE
-
-void qt_winrt_tzset()
-{
-}
-
-void qt_winrt__tzset()
-{
-}
-
-QT_END_NAMESPACE
-
-#endif // Q_OS_WINRT
diff --git a/src/corelib/kernel/qfunctions_winrt.h b/src/corelib/kernel/qfunctions_winrt_p.h
index d0c44be683..aa32747bc8 100644
--- a/src/corelib/kernel/qfunctions_winrt.h
+++ b/src/corelib/kernel/qfunctions_winrt_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -37,12 +37,23 @@
**
****************************************************************************/
-#ifndef QFUNCTIONS_WINRT_H
-#define QFUNCTIONS_WINRT_H
+#ifndef QFUNCTIONS_WINRT_P_H
+#define QFUNCTIONS_WINRT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
#include <QtCore/qglobal.h>
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && defined(Q_CC_MSVC)
#include <QtCore/QCoreApplication>
#include <QtCore/QThread>
@@ -50,6 +61,9 @@
#include <QtCore/QElapsedTimer>
#include <QtCore/qt_windows.h>
+#include <wrl.h>
+#include <windows.foundation.h>
+
// Convenience macros for handling HRESULT values
#define RETURN_IF_FAILED(msg, ret) \
if (FAILED(hr)) { \
@@ -75,86 +89,6 @@
#define Q_ASSERT_SUCCEEDED(hr) \
Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr)));
-#ifdef Q_OS_WINRT
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_BUILD_CORE_LIB
-#endif
-
-// Environment ------------------------------------------------------
-errno_t qt_fake_getenv_s(size_t*, char*, size_t, const char*);
-errno_t qt_fake__putenv_s(const char*, const char*);
-void qt_winrt_tzset();
-void qt_winrt__tzset();
-
-QT_END_NAMESPACE
-
-// As Windows Runtime lacks some standard functions used in Qt, these got
-// reimplemented. Other projects do this as well. Inline functions are used
-// that there is a central place to disable functions for newer versions if
-// they get available. There are no defines used anymore, because this
-// will break member functions of classes which are called like these
-// functions.
-// The other declarations available in this file are being used per
-// define inside qplatformdefs.h of the corresponding WinRT mkspec.
-
-#define generate_inline_return_func0(funcname, returntype) \
- inline returntype funcname() \
- { \
- return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(); \
- }
-#define generate_inline_return_func1(funcname, returntype, param1) \
- inline returntype funcname(param1 p1) \
- { \
- return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1); \
- }
-#define generate_inline_return_func2(funcname, returntype, prependnamespace, param1, param2) \
- inline returntype funcname(param1 p1, param2 p2) \
- { \
- return QT_PREPEND_NAMESPACE(prependnamespace##funcname)(p1, p2); \
- }
-#define generate_inline_return_func3(funcname, returntype, param1, param2, param3) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3) \
- { \
- return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2, p3); \
- }
-#define generate_inline_return_func4(funcname, returntype, prependnamespace, param1, param2, param3, param4) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4) \
- { \
- return QT_PREPEND_NAMESPACE(prependnamespace##funcname)(p1, p2, p3, p4); \
- }
-#define generate_inline_return_func5(funcname, returntype, param1, param2, param3, param4, param5) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
- { \
- return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2, p3, p4, p5); \
- }
-#define generate_inline_return_func6(funcname, returntype, param1, param2, param3, param4, param5, param6) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
- { \
- return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2, p3, p4, p5, p6); \
- }
-#define generate_inline_return_func7(funcname, returntype, param1, param2, param3, param4, param5, param6, param7) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, param7 p7) \
- { \
- return QT_PREPEND_NAMESPACE(qt_winrt_##funcname)(p1, p2, p3, p4, p5, p6, p7); \
- }
-
-typedef unsigned (__stdcall *StartAdressExFunc)(void *);
-typedef void(*StartAdressFunc)(void *);
-typedef int ( __cdecl *CompareFunc ) (const void *, const void *) ;
-
-generate_inline_return_func4(getenv_s, errno_t, qt_fake_, size_t *, char *, size_t, const char *)
-generate_inline_return_func2(_putenv_s, errno_t, qt_fake_, const char *, const char *)
-generate_inline_return_func0(tzset, void)
-generate_inline_return_func0(_tzset, void)
-
-namespace Microsoft {
- namespace WRL {
- template <typename T> class ComPtr;
- }
-}
-
QT_BEGIN_NAMESPACE
namespace QWinRTFunctions {
@@ -170,7 +104,7 @@ enum AwaitStyle
template <typename T>
static inline HRESULT _await_impl(const Microsoft::WRL::ComPtr<T> &asyncOp, AwaitStyle awaitStyle, uint timeout)
{
- Microsoft::WRL::ComPtr<IAsyncInfo> asyncInfo;
+ Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncInfo> asyncInfo;
HRESULT hr = asyncOp.As(&asyncInfo);
if (FAILED(hr))
return hr;
@@ -245,8 +179,6 @@ static inline HRESULT await(const Microsoft::WRL::ComPtr<T> &asyncOp, U *results
QT_END_NAMESPACE
-#endif // Q_OS_WINRT
-
-#endif // Q_OS_WIN
+#endif // Q_OS_WIN && Q_CC_MSVC
-#endif // QFUNCTIONS_WINRT_H
+#endif // QFUNCTIONS_WINRT_P_H
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp
index 02de2339a5..cbf31bcb2f 100644
--- a/src/corelib/kernel/qsharedmemory_win.cpp
+++ b/src/corelib/kernel/qsharedmemory_win.cpp
@@ -101,12 +101,8 @@ HANDLE QSharedMemoryPrivate::handle()
errorString = QSharedMemory::tr("%1: unable to make key").arg(function);
return 0;
}
-#if defined(Q_OS_WINRT)
- hand = OpenFileMappingFromApp(FILE_MAP_ALL_ACCESS, FALSE, reinterpret_cast<PCWSTR>(nativeKey.utf16()));
-#else
hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false,
reinterpret_cast<const wchar_t*>(nativeKey.utf16()));
-#endif
if (!hand) {
setErrorString(function);
return 0;
@@ -136,13 +132,8 @@ bool QSharedMemoryPrivate::create(int size)
}
// Create the file mapping.
-#if defined(Q_OS_WINRT)
- hand = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, size,
- reinterpret_cast<PCWSTR>(nativeKey.utf16()));
-#else
hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size,
reinterpret_cast<const wchar_t*>(nativeKey.utf16()));
-#endif
setErrorString(function);
// hand is valid when it already exists unlike unix so explicitly check
@@ -153,11 +144,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
{
// Grab a pointer to the memory block
int permissions = (mode == QSharedMemory::ReadOnly ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS);
-#if defined(Q_OS_WINRT)
- memory = (void *)MapViewOfFileFromApp(handle(), permissions, 0, 0);
-#else
memory = (void *)MapViewOfFile(handle(), permissions, 0, 0, 0);
-#endif
if (0 == memory) {
setErrorString(QLatin1String("QSharedMemory::attach"));
cleanHandle();
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index a735e12925..6a250f5f3a 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -76,7 +76,6 @@ namespace {
static QString windowsErrorString(int errorCode)
{
QString ret;
-#ifndef Q_OS_WINRT
wchar_t *string = 0;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
@@ -87,17 +86,6 @@ static QString windowsErrorString(int errorCode)
NULL);
ret = QString::fromWCharArray(string);
LocalFree((HLOCAL)string);
-#else
- wchar_t errorString[1024];
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- errorCode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&errorString,
- sizeof(errorString)/sizeof(wchar_t),
- NULL);
- ret = QString::fromWCharArray(errorString);
-#endif // Q_OS_WINRT
if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
ret = QString::fromLatin1("The specified module could not be found.");
diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp
index 2b35803291..d19476db4a 100644
--- a/src/corelib/kernel/qsystemsemaphore_win.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_win.cpp
@@ -85,14 +85,8 @@ HANDLE QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode)
// Create it if it doesn't already exists.
if (semaphore == 0) {
-#if defined(Q_OS_WINRT)
- semaphore = CreateSemaphoreEx(0, initialValue, MAXLONG,
- reinterpret_cast<const wchar_t*>(fileName.utf16()),
- 0, SEMAPHORE_ALL_ACCESS);
-#else
semaphore = CreateSemaphore(0, initialValue, MAXLONG,
reinterpret_cast<const wchar_t*>(fileName.utf16()));
-#endif
if (semaphore == NULL)
setErrorString(QLatin1String("QSystemSemaphore::handle"));
}
diff --git a/src/corelib/kernel/qtestsupport_core.cpp b/src/corelib/kernel/qtestsupport_core.cpp
index 428ebbd652..928c8021bc 100644
--- a/src/corelib/kernel/qtestsupport_core.cpp
+++ b/src/corelib/kernel/qtestsupport_core.cpp
@@ -49,9 +49,7 @@ Q_CORE_EXPORT void QTestPrivate::qSleep(int ms)
{
Q_ASSERT(ms > 0);
-#if defined(Q_OS_WINRT)
- WaitForSingleObjectEx(GetCurrentThread(), ms, true);
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
Sleep(uint(ms));
#else
struct timespec ts = { time_t(ms / 1000), (ms % 1000) * 1000 * 1000 };
diff --git a/src/corelib/kernel/qwineventnotifier.cpp b/src/corelib/kernel/qwineventnotifier.cpp
index 0c574e9a4b..b306e3aba1 100644
--- a/src/corelib/kernel/qwineventnotifier.cpp
+++ b/src/corelib/kernel/qwineventnotifier.cpp
@@ -39,11 +39,7 @@
#include "qwineventnotifier_p.h"
-#ifdef Q_OS_WINRT
-#include "qeventdispatcher_winrt_p.h"
-#else
#include "qeventdispatcher_win_p.h"
-#endif
#include "qcoreapplication.h"
#include <private/qthread_p.h>
@@ -235,21 +231,6 @@ bool QWinEventNotifier::event(QEvent * e)
return false;
}
-#if defined(Q_OS_WINRT)
-
-bool QWinEventNotifierPrivate::registerWaitObject()
-{
- Q_UNIMPLEMENTED();
- return false;
-}
-
-void QWinEventNotifierPrivate::unregisterWaitObject()
-{
- Q_UNIMPLEMENTED();
-}
-
-#else // defined(Q_OS_WINRT)
-
static void CALLBACK wfsoCallback(void *context, BOOLEAN /*ignore*/)
{
QWinEventNotifierPrivate *nd = reinterpret_cast<QWinEventNotifierPrivate *>(context);
@@ -287,6 +268,4 @@ void QWinEventNotifierPrivate::unregisterWaitObject()
qErrnoWarning("QWinEventNotifier: UnregisterWaitEx failed.");
}
-#endif // !defined(Q_OS_WINRT)
-
QT_END_NAMESPACE