diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2018-11-23 09:47:24 +0100 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@qt.io> | 2018-11-28 06:36:18 +0000 |
commit | 3c8b439d84a0ef646d49126f2cfdc59f1eccb883 (patch) | |
tree | 69b662956c7515c05d73b2e0cdd7be150f787508 | |
parent | 3cf061dc8da4d564de06efa6800749f3eacf47eb (diff) | |
download | qtlocation-3c8b439d84a0ef646d49126f2cfdc59f1eccb883.tar.gz |
winrt: Add nativeStatus helper functions
Gets rid of duplicated code.
Change-Id: I4635b23c5ae431867299eeeafd4bd260f8ba156f
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index d995fd79..8a72eb39 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -86,8 +86,24 @@ public: EventRegistrationToken positionToken; QMutex mutex; bool updatesOngoing; + + PositionStatus nativeStatus() const; }; +PositionStatus QGeoPositionInfoSourceWinRTPrivate::nativeStatus() const +{ + qCDebug(lcPositioningWinRT) << __FUNCTION__; + + PositionStatus status; + HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([this, &status]() { + return locator->get_LocationStatus(&status); + }); + if (FAILED(hr)) { + qErrnoWarning(hr, "Could not query status"); + return PositionStatus_NotAvailable; + } + return status; +} QGeoPositionInfoSourceWinRT::QGeoPositionInfoSourceWinRT(QObject *parent) : QGeoPositionInfoSource(parent) @@ -169,13 +185,7 @@ QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceWinRT::supporte { Q_D(const QGeoPositionInfoSourceWinRT); - PositionStatus status; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d, &status]() { - HRESULT hr = d->locator->get_LocationStatus(&status); - return hr; - }); - if (FAILED(hr)) - return QGeoPositionInfoSource::NoPositioningMethods; + PositionStatus status = d->nativeStatus(); qCDebug(lcPositioningWinRT) << __FUNCTION__ << status; switch (status) { @@ -427,13 +437,7 @@ bool QGeoPositionInfoSourceWinRT::checkNativeState() Q_D(QGeoPositionInfoSourceWinRT); qCDebug(lcPositioningWinRT) << __FUNCTION__; - PositionStatus status; - HRESULT hr = d->locator->get_LocationStatus(&status); - if (FAILED(hr)) { - setError(QGeoPositionInfoSource::UnknownSourceError); - qErrnoWarning(hr, "Could not query status"); - return false; - } + PositionStatus status = d->nativeStatus(); bool result = false; switch (status) { |