From 9783cdd14fdd835d4bdc92d6cf933cd9cf7a9009 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Tue, 4 May 2021 18:48:55 +0200 Subject: QtPositioning: fix source detection When an 'nmeaSource' property is specified, it is read before the component is completed. At this point, a valid position source can be created to read the data from the specified source. After that, when the component is completed, a new position source is created based on the 'name' property, even if it's empty. This results in the initial valid position source being overridden by a default one (depending on the system configuration it may or may not provide valid positioning information). This patch adds a check that if nmeaSource is used, we do not try to override it and ignore the 'name' property. Fixes: QTBUG-85636 Change-Id: I6acdcdaf7c7f8ee168c1d48d9eb5dbc7d1838af3 Reviewed-by: Qt CI Bot Reviewed-by: Alex Blasche --- src/positioningquick/qdeclarativepositionsource.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/positioningquick/qdeclarativepositionsource.cpp b/src/positioningquick/qdeclarativepositionsource.cpp index 599bb29b..af1e9904 100644 --- a/src/positioningquick/qdeclarativepositionsource.cpp +++ b/src/positioningquick/qdeclarativepositionsource.cpp @@ -193,6 +193,12 @@ void QDeclarativePositionSource::setName(const QString &newName) */ void QDeclarativePositionSource::tryAttach(const QString &newName, bool useFallback) { + if (m_nmeaFile != nullptr || m_nmeaSocket != nullptr) { + if (!m_providerName.isEmpty()) + qWarning("Both nmeaSource and name parameters are specified. nmeaSource will be used."); + return; + } + const QString previousName = name(); const bool sourceExisted = m_positionSource; m_providerName = newName; -- cgit v1.2.1