diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2021-05-04 18:48:55 +0200 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2021-05-06 12:38:40 +0200 |
commit | 9783cdd14fdd835d4bdc92d6cf933cd9cf7a9009 (patch) | |
tree | da570d7a3e2119210b2643acf1d8848038892ee0 | |
parent | 6ada7528a3367a7007665f86e1f2ebc2774fe494 (diff) | |
download | qtlocation-9783cdd14fdd835d4bdc92d6cf933cd9cf7a9009.tar.gz |
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 <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | src/positioningquick/qdeclarativepositionsource.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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; |