diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 5bfe681e73d..d104f9ff5ac 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -209,6 +209,16 @@ QT_BEGIN_NAMESPACE Constructs a new region which is equal to region \a r. */ +/*! + \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) diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 94e2db26487..d66f80fcde4 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(&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 7292841e5df..d24435198e6 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() { {