summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2021-06-02 07:05:25 +0300
committerJuha Vuolle <juha.vuolle@insta.fi>2021-06-04 09:16:34 +0300
commit465e7475563db168af60251e43e5e770f3e665b8 (patch)
tree6d59d4182560bba2840bbb8560ef36dde6b30b28 /src/plugins
parent530e6856a9345c87def7147be4d727aec26ec2fa (diff)
Add Co(Un)Initialize call to windows backend
The sensors are accessed through the COM library which requires that the initialization routines are done. Task-number: QTBUG-92510 Change-Id: Idf65b0076432bebbab0de9f24b5e9711d471d193 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/sensors/winrt/main.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/sensors/winrt/main.cpp b/src/plugins/sensors/winrt/main.cpp
index e66e0ade..2b868e2f 100644
--- a/src/plugins/sensors/winrt/main.cpp
+++ b/src/plugins/sensors/winrt/main.cpp
@@ -52,6 +52,7 @@
#include <QtSensors/QSensorBackendFactory>
#include <QtSensors/QSensorManager>
#include <QtSensors/QSensorPluginInterface>
+#include <wrl.h>
class WinRtSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory
{
@@ -60,8 +61,17 @@ class WinRtSensorPlugin : public QObject, public QSensorPluginInterface, public
Q_INTERFACES(QSensorPluginInterface)
public:
+ ~WinRtSensorPlugin()
+ {
+ CoUninitialize();
+ }
+
void registerSensors() override
{
+ if (FAILED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) {
+ qErrnoWarning("CoInitializeEx() failed.");
+ return;
+ }
QSensorManager::registerBackend(QAccelerometer::sensorType, QByteArrayLiteral("WinRtAccelerometer"), this);
QSensorManager::registerBackend(QCompass::sensorType, QByteArrayLiteral("WinRtCompass"), this);
QSensorManager::registerBackend(QGyroscope::sensorType, QByteArrayLiteral("WinRtGyroscope"), this);