summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-02-10 15:43:15 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-02-11 19:26:05 +0000
commit4bc923b6281dcbdc610133f1c47523999ef8c153 (patch)
treedbdfc34e6a79d3824d094c62a29544b725b2b952 /src/gui/painting
parentd55b685d237be7a6bd01b52600bcc9ffcee4e2a5 (diff)
QMatrix, QTransform: restore nothrow move special members
The user-defined copy assignment and (on QMatrix) copy constructors inhibit the move special member functions. We cannot do something about it in Qt 5, because these classes are exported (which they shouldn't be), and because making them trivially copyable might change how they are passed to functions by value, so we need to supply all the missing member functions manually. Change-Id: I59e480d7ba02cac7e3d654cb3345f541e0701f4c Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qmatrix.cpp9
-rw-r--r--src/gui/painting/qmatrix.h13
-rw-r--r--src/gui/painting/qtransform.cpp4
-rw-r--r--src/gui/painting/qtransform.h18
4 files changed, 34 insertions, 10 deletions
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index 80a8f361d9..681490e347 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -244,11 +244,11 @@ QMatrix::QMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy)
{
}
-
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
/*!
Constructs a matrix that is a copy of the given \a matrix.
*/
-QMatrix::QMatrix(const QMatrix &matrix)
+QMatrix::QMatrix(const QMatrix &matrix) Q_DECL_NOTHROW
: _m11(matrix._m11)
, _m12(matrix._m12)
, _m21(matrix._m21)
@@ -257,6 +257,7 @@ QMatrix::QMatrix(const QMatrix &matrix)
, _dy(matrix._dy)
{
}
+#endif
/*!
Sets the matrix elements to the specified values, \a m11, \a m12,
@@ -1063,10 +1064,11 @@ QMatrix QMatrix::operator *(const QMatrix &m) const
return QMatrix(tm11, tm12, tm21, tm22, tdx, tdy, true);
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
/*!
Assigns the given \a matrix's values to this matrix.
*/
-QMatrix &QMatrix::operator=(const QMatrix &matrix)
+QMatrix &QMatrix::operator=(const QMatrix &matrix) Q_DECL_NOTHROW
{
_m11 = matrix._m11;
_m12 = matrix._m12;
@@ -1076,6 +1078,7 @@ QMatrix &QMatrix::operator=(const QMatrix &matrix)
_dy = matrix._dy;
return *this;
}
+#endif
/*!
\since 4.2
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index 342898b561..b28c8433cd 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -60,7 +60,16 @@ public:
QMatrix();
QMatrix(qreal m11, qreal m12, qreal m21, qreal m22,
qreal dx, qreal dy);
- QMatrix(const QMatrix &matrix);
+
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ // ### Qt 6: remove; the compiler-generated ones are fine!
+ QMatrix &operator=(QMatrix &&other) Q_DECL_NOTHROW // = default
+ { memcpy(this, &other, sizeof(QMatrix)); return *this; }
+ QMatrix &operator=(const QMatrix &) Q_DECL_NOTHROW; // = default
+ QMatrix(QMatrix &&other) Q_DECL_NOTHROW // = default
+ { memcpy(this, &other, sizeof(QMatrix)); }
+ QMatrix(const QMatrix &other) Q_DECL_NOTHROW; // = default
+#endif
void setMatrix(qreal m11, qreal m12, qreal m21, qreal m22,
qreal dx, qreal dy);
@@ -106,8 +115,6 @@ public:
QMatrix &operator*=(const QMatrix &);
QMatrix operator*(const QMatrix &o) const;
- QMatrix &operator=(const QMatrix &);
-
operator QVariant() const;
private:
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 3e2a002148..a0596d1a07 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -1011,10 +1011,11 @@ QTransform QTransform::operator*(const QTransform &m) const
element of this matrix.
*/
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
/*!
Assigns the given \a matrix's values to this matrix.
*/
-QTransform & QTransform::operator=(const QTransform &matrix)
+QTransform & QTransform::operator=(const QTransform &matrix) Q_DECL_NOTHROW
{
affine._m11 = matrix.affine._m11;
affine._m12 = matrix.affine._m12;
@@ -1030,6 +1031,7 @@ QTransform & QTransform::operator=(const QTransform &matrix)
return *this;
}
+#endif
/*!
Resets the matrix to an identity matrix, i.e. all elements are set
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index 8e97d1eb6f..470a5565e1 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -74,6 +74,19 @@ public:
qreal h22, qreal dx, qreal dy);
explicit QTransform(const QMatrix &mtx);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ // ### Qt 6: remove; the compiler-generated ones are fine!
+ QTransform &operator=(QTransform &&other) Q_DECL_NOTHROW // = default
+ { memcpy(this, &other, sizeof(QTransform)); return *this; }
+ QTransform &operator=(const QTransform &) Q_DECL_NOTHROW; // = default
+ QTransform(QTransform &&other) Q_DECL_NOTHROW // = default
+ : affine(Qt::Uninitialized)
+ { memcpy(this, &other, sizeof(QTransform)); }
+ QTransform(const QTransform &other) Q_DECL_NOTHROW // = default
+ : affine(Qt::Uninitialized)
+ { memcpy(this, &other, sizeof(QTransform)); }
+#endif
+
bool isAffine() const;
bool isIdentity() const;
bool isInvertible() const;
@@ -124,8 +137,6 @@ public:
QTransform &operator*=(const QTransform &);
QTransform operator*(const QTransform &o) const;
- QTransform &operator=(const QTransform &);
-
operator QVariant() const;
void reset();
@@ -180,9 +191,10 @@ private:
mutable uint m_type : 5;
mutable uint m_dirty : 5;
-
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
class Private;
Private *d;
+#endif
};
Q_DECLARE_TYPEINFO(QTransform, Q_MOVABLE_TYPE);