From c8d3eb35e73e650e73fcc47c78af6d86ff58bfd9 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 12 Jul 2019 15:02:09 +0200 Subject: Fixup move semantics of QColorSpace Stop using QExplicitlySharedDataPointer, makes it possible to inline the move constructor and assign operator. Also protect other methods from nullptr d_ptr, and change the default constructed value to also have a null d_ptr, to match the result after a move. Change-Id: I40928feef90cc956ef84d0516a77b0ee0f8986c7 Reviewed-by: Allan Sandfeld Jensen --- .../gui/painting/qcolorspace/tst_qcolorspace.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp index bc1a45013c..9e13dc80b4 100644 --- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -47,6 +47,7 @@ public: tst_QColorSpace(); private slots: + void movable(); void namedColorSpaces_data(); void namedColorSpaces(); @@ -75,6 +76,28 @@ tst_QColorSpace::tst_QColorSpace() { } +void tst_QColorSpace::movable() +{ + QColorSpace cs1 = QColorSpace::SRgb; + QColorSpace cs2 = QColorSpace::SRgbLinear; + QVERIFY(cs1.isValid()); + QVERIFY(cs2.isValid()); + QCOMPARE(cs1.colorSpaceId(), QColorSpace::SRgb); + + cs2 = std::move(cs1); + QVERIFY(!cs1.isValid()); + QVERIFY(cs2.isValid()); + QCOMPARE(cs2.colorSpaceId(), QColorSpace::SRgb); + QCOMPARE(cs1.colorSpaceId(), QColorSpace::Undefined); + QCOMPARE(cs1, QColorSpace()); + + QColorSpace cs3(std::move(cs2)); + QVERIFY(!cs2.isValid()); + QVERIFY(cs3.isValid()); + QCOMPARE(cs3.colorSpaceId(), QColorSpace::SRgb); + QCOMPARE(cs2.colorSpaceId(), QColorSpace::Undefined); +} + void tst_QColorSpace::namedColorSpaces_data() { QTest::addColumn("colorSpaceId"); -- cgit v1.2.3