diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-08-25 11:23:18 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-02-13 18:18:32 +0000 |
commit | afc7da09ec01b1658451d36c52f22c0d203f593d (patch) | |
tree | 737e3497b4cfb3df14a8d678b2fbcd0fa104d4cf | |
parent | 0df5c366e50b9533fd8ea3f31c4c360ae7f4c5b6 (diff) |
QRegion: add move ctor
After this change, this was the distribution of calls in
QtGui and QtWidgets when the patch was developed for 5.4:
QtGui QtWidgets
move 23 63
copy 23 36
Change-Id: If3f536e52fc242c585e7fa0662049c0657efcc9c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
-rw-r--r-- | src/gui/painting/qregion.cpp | 10 | ||||
-rw-r--r-- | src/gui/painting/qregion.h | 2 | ||||
-rw-r--r-- | tests/auto/gui/painting/qregion/tst_qregion.cpp | 23 |
3 files changed, 35 insertions, 0 deletions
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 5bfe681e73..d104f9ff5a 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -210,6 +210,16 @@ QT_BEGIN_NAMESPACE */ /*! + \fn QRegion::QRegion(QRegion &&other) + \since 5.7 + + Move-constructs a new region from region \a other. + After the call, \a other is null. + + \sa isNull() +*/ + +/*! \fn QRegion::QRegion(const QBitmap &bm) Constructs a region from the bitmap \a bm. diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 94e2db2648..d66f80fcde 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -68,6 +68,8 @@ public: QRegion(const QRect &r, RegionType t = Rectangle); QRegion(const QPolygon &pa, Qt::FillRule fillRule = Qt::OddEvenFill); QRegion(const QRegion ®ion); + QRegion(QRegion &&other) Q_DECL_NOTHROW + : d(other.d) { other.d = const_cast<QRegionData*>(&shared_empty); } QRegion(const QBitmap &bitmap); ~QRegion(); QRegion &operator=(const QRegion &); diff --git a/tests/auto/gui/painting/qregion/tst_qregion.cpp b/tests/auto/gui/painting/qregion/tst_qregion.cpp index 7292841e5d..d24435198e 100644 --- a/tests/auto/gui/painting/qregion/tst_qregion.cpp +++ b/tests/auto/gui/painting/qregion/tst_qregion.cpp @@ -45,6 +45,7 @@ public: tst_QRegion(); private slots: + void moveSemantics(); void boundingRect(); void rects(); void swap(); @@ -93,6 +94,28 @@ tst_QRegion::tst_QRegion() { } +void tst_QRegion::moveSemantics() +{ + const QRegion rect(QRect(0, 0, 100, 100)); + + // move assignment + { + QRegion r1 = rect; + QRegion r2; + r2 = std::move(r1); + QVERIFY(r1.isNull()); + QCOMPARE(r2, rect); + } + + // move construction + { + QRegion r1 = rect; + QRegion r2 = std::move(r1); + QVERIFY(r1.isNull()); + QCOMPARE(r2, rect); + } +} + void tst_QRegion::boundingRect() { { |