diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-07-12 15:02:09 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-09-02 18:37:07 +0200 |
commit | c8d3eb35e73e650e73fcc47c78af6d86ff58bfd9 (patch) | |
tree | 1ed478548c7593476ea98faa8136567a66a7a60c /tests | |
parent | 162e23d838101ddcd8e6416dd346465ac20bd05d (diff) |
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 <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
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<QColorSpace::ColorSpaceId>("colorSpaceId"); |