summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/painting/qregion.cpp10
-rw-r--r--src/gui/painting/qregion.h2
-rw-r--r--tests/auto/gui/painting/qregion/tst_qregion.cpp23
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 &region);
+ 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()
{
{