From 25493cbb07f8cbc6c6d12cfc575a71875be06692 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 26 Nov 2018 13:14:29 +0100 Subject: winrt: Restart location handler on setUpdateInterval if necessary Windows' backend will complain if we try to set the report interval while being subscribed to position changes so we have to remove this registration and redo it when the new interval is in effect. Change-Id: I5b3f23a7b6e530dd0a3f673e2b8ce6f5102b7eb1 Reviewed-by: Andre de la Rocha Reviewed-by: Miguel Costa Reviewed-by: Alex Blasche --- src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index 9616b1d8..fa537af7 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -266,6 +266,11 @@ void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec) if (msec != 0 && msec < minimumUpdateInterval()) msec = minimumUpdateInterval(); + const bool needsRestart = d->positionToken.value != 0; + + if (needsRestart) + stopHandler(); + HRESULT hr = d->locator->put_ReportInterval(msec); if (FAILED(hr)) { setError(QGeoPositionInfoSource::UnknownSourceError); @@ -276,6 +281,9 @@ void QGeoPositionInfoSourceWinRT::setUpdateInterval(int msec) d->periodicTimer.setInterval(qMax(msec, minimumUpdateInterval())); QGeoPositionInfoSource::setUpdateInterval(msec); + + if (needsRestart) + startHandler(); } int QGeoPositionInfoSourceWinRT::minimumUpdateInterval() const -- cgit v1.2.1