summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/winrt/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/sensors/winrt/main.cpp')
-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);