diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-07-29 10:59:47 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-08-03 07:35:50 +0200 |
commit | 117d4bf2bd04fb9702938233a00052b965c724a8 (patch) | |
tree | a3ea5b405e8a6b98c953a70dda0a183d9cc5ebe8 | |
parent | 43dde53b5b0dfae14bf0bde97bf4709344131acd (diff) | |
download | qtlocation-117d4bf2bd04fb9702938233a00052b965c724a8.tar.gz |
Clean up mix of polymorph and value semantics
QGeoManeuver had a protected constructor only to allow the test to
replace the private implementation, which is polymorph. There is no use
of this possibility to override the implementation of the class outside
the test.
If we want to bring this back, then a factory that the service provider
plugins implement and through which the framework creates the
implementations would be the typical architecture, without forcing the
subclassing of value types with the risk for slicing or memory leaks
when destructors are not virtual.
Pick-to: 6.2
Task-number: QTBUG-105206
Change-Id: I3358da3939c43dfb83c4b2b10a792044590263f7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/location/maps/qgeomaneuver.cpp | 3 | ||||
-rw-r--r-- | src/location/maps/qgeomaneuver.h | 3 | ||||
-rw-r--r-- | tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp | 48 | ||||
-rw-r--r-- | tests/auto/qgeomaneuver/tst_qgeomaneuver.h | 1 |
4 files changed, 0 insertions, 55 deletions
diff --git a/src/location/maps/qgeomaneuver.cpp b/src/location/maps/qgeomaneuver.cpp index 26d3592f..0ed9a881 100644 --- a/src/location/maps/qgeomaneuver.cpp +++ b/src/location/maps/qgeomaneuver.cpp @@ -296,9 +296,6 @@ QGeoCoordinate QGeoManeuver::waypoint() const return d_ptr->waypoint(); } -QGeoManeuver::QGeoManeuver(const QSharedDataPointer<QGeoManeuverPrivate> &dd) - : d_ptr(dd) {} - /*! Sets the extended attributes \a extendedAttributes associated with this maneuver. diff --git a/src/location/maps/qgeomaneuver.h b/src/location/maps/qgeomaneuver.h index e9a65927..ce81949c 100644 --- a/src/location/maps/qgeomaneuver.h +++ b/src/location/maps/qgeomaneuver.h @@ -106,9 +106,6 @@ public: void setExtendedAttributes(const QVariantMap &extendedAttributes); QVariantMap extendedAttributes() const; -protected: - QGeoManeuver(const QSharedDataPointer<QGeoManeuverPrivate> &dd); - private: QSharedDataPointer<QGeoManeuverPrivate> d_ptr; diff --git a/tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp b/tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp index 8411deff..be9a0ad4 100644 --- a/tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp +++ b/tests/auto/qgeomaneuver/tst_qgeomaneuver.cpp @@ -29,29 +29,6 @@ #include "tst_qgeomaneuver.h" #include <QtLocation/private/qgeomaneuver_p.h> -class QGeoManeuverPrivateDefaultAlt : public QGeoManeuverPrivateDefault -{ -public: - QGeoManeuverPrivateDefaultAlt() {} - QGeoManeuverPrivateDefaultAlt(const QGeoManeuverPrivateDefaultAlt &other) - : QGeoManeuverPrivateDefault(other) {} - ~QGeoManeuverPrivateDefaultAlt() {} - - QString text() const override - { - return QStringLiteral("QGeoManeuverPrivateDefaultAlt"); // To identify this is actually a QGeoManeuverPrivateDefaultAlt - } -}; - -class QGeoManeuverAlt : public QGeoManeuver -{ -public: - QGeoManeuverAlt() - : QGeoManeuver(QSharedDataPointer<QGeoManeuverPrivate>(new QGeoManeuverPrivateDefaultAlt())) - { - } -}; - tst_QGeoManeuver::tst_QGeoManeuver() { } @@ -248,29 +225,4 @@ void tst_QGeoManeuver::operators() QVERIFY(!(qgeomaneuver != qgeomaneuvercopy)); } -void tst_QGeoManeuver::alternateImplementation() -{ - QGeoManeuver qgeomaneuver; - QGeoManeuver qgeomaneuvercopy = qgeomaneuver; - - QVERIFY(qgeomaneuvercopy == qgeomaneuver); - - qgeomaneuvercopy.setDirection(QGeoManeuver::DirectionForward); - qgeomaneuvercopy.setInstructionText("Turn left in 80m"); - qgeomaneuvercopy.setTimeToNextInstruction(70); - qgeomaneuvercopy.setDistanceToNextInstruction(56065.45); - - QVERIFY(qgeomaneuvercopy != qgeomaneuver); - - QGeoManeuverAlt mAlt; - QGeoManeuver m = mAlt; - - QCOMPARE(m.instructionText(), "QGeoManeuverPrivateDefaultAlt"); - m = qgeomaneuvercopy; - QCOMPARE(m.instructionText(), "Turn left in 80m"); - m = mAlt; - QCOMPARE(m.instructionText(), "QGeoManeuverPrivateDefaultAlt"); -} - - QTEST_APPLESS_MAIN(tst_QGeoManeuver); diff --git a/tests/auto/qgeomaneuver/tst_qgeomaneuver.h b/tests/auto/qgeomaneuver/tst_qgeomaneuver.h index 5fc71709..87168838 100644 --- a/tests/auto/qgeomaneuver/tst_qgeomaneuver.h +++ b/tests/auto/qgeomaneuver/tst_qgeomaneuver.h @@ -63,7 +63,6 @@ private Q_SLOTS: void waypoint_data(); void isValid(); void operators(); - void alternateImplementation(); //End Unit Test for QGeoRouteManeuver }; |