summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2015-05-18 12:58:04 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-05-20 13:34:45 +0000
commit58d8b5e84ac6952b411cff3bca7336073349290e (patch)
treeb67841b21d6f524badc7dd219e693fd430b05065 /src
parentac90417d676a7691c01af7730172f60bf690d4ee (diff)
downloadqtlocation-58d8b5e84ac6952b411cff3bca7336073349290e.tar.gz
Fix crash when initiating map flick w/o QtPositioning import
A map flick requires a QPropertyAnimation for a QGeoCoordinate. The required animation interpolator is exported by the QtPositioning QML plugin. In general a QML Location app should always import QtPositioning as well. In this case the import was missing and subsequently the interpolator for the QGeoCoordinate was never registered. This patch ensures that the QtLocation QML code that requires the animation registers the interpolator in addition to the regular QtPositioning registration. Change-Id: I61759418f0cdf1cb30ff946cc325a112e90c1a2f Task-number: QTBUG-46147 Reviewed-by: Michal Klocek <michal.klocek@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/imports/location/qdeclarativegeomapgesturearea.cpp15
-rw-r--r--src/imports/positioning/positioning.cpp1
-rw-r--r--src/imports/positioning/qdeclarativegeocoordinateanimation.cpp16
-rw-r--r--src/imports/positioning/qdeclarativegeocoordinateanimation_p.h3
-rw-r--r--src/positioning/qgeoprojection.cpp15
-rw-r--r--src/positioning/qgeoprojection_p.h5
6 files changed, 36 insertions, 19 deletions
diff --git a/src/imports/location/qdeclarativegeomapgesturearea.cpp b/src/imports/location/qdeclarativegeomapgesturearea.cpp
index 07fd58e5..05891626 100644
--- a/src/imports/location/qdeclarativegeomapgesturearea.cpp
+++ b/src/imports/location/qdeclarativegeomapgesturearea.cpp
@@ -47,6 +47,7 @@
#include <QtQuick/QQuickWindow>
#include <QPropertyAnimation>
#include <QDebug>
+#include <QtPositioning/private/qgeoprojection_p.h>
#include "math.h"
#include "qgeomap_p.h"
#include "qdoublevector2d_p.h"
@@ -330,6 +331,20 @@ QT_BEGIN_NAMESPACE
The corresponding handler is \c onFlickFinished.
*/
+static void registerQGeoCoordinateInterpolator()
+{
+ // required by QPropertyAnimation
+ qRegisterAnimationInterpolator<QGeoCoordinate>(geoCoordinateInterpolator);
+}
+Q_CONSTRUCTOR_FUNCTION(registerQGeoCoordinateInterpolator)
+
+static void unregisterQGeoCoordinateInterpolator()
+{
+ qRegisterAnimationInterpolator<QGeoCoordinate>(
+ (QVariant (*)(const QGeoCoordinate &, const QGeoCoordinate &, qreal))0);
+}
+Q_DESTRUCTOR_FUNCTION(unregisterQGeoCoordinateInterpolator)
+
QDeclarativeGeoMapGestureArea::QDeclarativeGeoMapGestureArea(QDeclarativeGeoMap *map, QObject *parent)
: QObject(parent),
declarativeMap_(map),
diff --git a/src/imports/positioning/positioning.cpp b/src/imports/positioning/positioning.cpp
index 2a010be7..743b73df 100644
--- a/src/imports/positioning/positioning.cpp
+++ b/src/imports/positioning/positioning.cpp
@@ -34,6 +34,7 @@
#include <QtPositioning/private/qdeclarativegeoaddress_p.h>
#include <QtPositioning/private/qdeclarativegeolocation_p.h>
+#include <QtPositioning/private/qgeoprojection_p.h>
#include "qdeclarativepositionsource_p.h"
#include "qdeclarativeposition_p.h"
diff --git a/src/imports/positioning/qdeclarativegeocoordinateanimation.cpp b/src/imports/positioning/qdeclarativegeocoordinateanimation.cpp
index 3f01cbc0..8bb677ad 100644
--- a/src/imports/positioning/qdeclarativegeocoordinateanimation.cpp
+++ b/src/imports/positioning/qdeclarativegeocoordinateanimation.cpp
@@ -33,7 +33,6 @@
#include "qdeclarativegeocoordinateanimation_p.h"
#include <QtQuick/private/qquickanimation_p_p.h>
-#include <QtPositioning/private/qgeoprojection_p.h>
#include <QtPositioning/private/qdoublevector2d_p.h>
QT_BEGIN_NAMESPACE
@@ -94,19 +93,4 @@ void QDeclarativeGeoCoordinateAnimation::setTo(const QGeoCoordinate &t)
QQuickPropertyAnimation::setTo(QVariant::fromValue(t));
}
-QVariant geoCoordinateInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
-{
- if (from == to) {
- if (progress < 0.5) {
- return QVariant::fromValue(from);
- } else {
- return QVariant::fromValue(to);
- }
- }
-
- QGeoCoordinate result = QGeoProjection::coordinateInterpolation(from, to, progress);
-
- return QVariant::fromValue(result);
-}
-
QT_END_NAMESPACE
diff --git a/src/imports/positioning/qdeclarativegeocoordinateanimation_p.h b/src/imports/positioning/qdeclarativegeocoordinateanimation_p.h
index 26b6ebb6..2aafc8f6 100644
--- a/src/imports/positioning/qdeclarativegeocoordinateanimation_p.h
+++ b/src/imports/positioning/qdeclarativegeocoordinateanimation_p.h
@@ -39,9 +39,6 @@
QT_BEGIN_NAMESPACE
-
-QVariant geoCoordinateInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress);
-
class QDeclarativeGeoCoordinateAnimation : public QQuickPropertyAnimation
{
Q_OBJECT
diff --git a/src/positioning/qgeoprojection.cpp b/src/positioning/qgeoprojection.cpp
index bc414eb2..0d3543e4 100644
--- a/src/positioning/qgeoprojection.cpp
+++ b/src/positioning/qgeoprojection.cpp
@@ -129,4 +129,19 @@ QGeoCoordinate QGeoProjection::coordinateInterpolation(const QGeoCoordinate &fro
return result;
}
+QVariant geoCoordinateInterpolator(const QGeoCoordinate &from, const QGeoCoordinate &to, qreal progress)
+{
+ if (from == to) {
+ if (progress < 0.5) {
+ return QVariant::fromValue(from);
+ } else {
+ return QVariant::fromValue(to);
+ }
+ }
+
+ QGeoCoordinate result = QGeoProjection::coordinateInterpolation(from, to, progress);
+
+ return QVariant::fromValue(result);
+}
+
QT_END_NAMESPACE
diff --git a/src/positioning/qgeoprojection_p.h b/src/positioning/qgeoprojection_p.h
index d4925ee5..f1b32525 100644
--- a/src/positioning/qgeoprojection_p.h
+++ b/src/positioning/qgeoprojection_p.h
@@ -49,6 +49,7 @@
#endif
#include <qglobal.h>
+#include <QtCore/qvariant.h>
#include "qpositioningglobal.h"
QT_BEGIN_NAMESPACE
@@ -56,6 +57,10 @@ QT_BEGIN_NAMESPACE
class QGeoCoordinate;
class QDoubleVector2D;
+Q_POSITIONING_EXPORT QVariant geoCoordinateInterpolator(const QGeoCoordinate &from,
+ const QGeoCoordinate &to,
+ qreal progress);
+
class Q_POSITIONING_EXPORT QGeoProjection
{
public: