QtGui: make all Q_DECLARE_SHARED types nothrow move-assignable

Excepting QBitmap and the QTextFormat heirarchy, which don't
have 100% value semantics (still pondering them).

In QPolygon(F), adding the move assignment operator disables
the implicitly-defined copy assignment operator, which therefore
have to be made user-defined. That doesn't change the ABI of
the class, since the base class QVector already had a user-defined
copy assignment operator.

Change-Id: I0b111c1d21cf47f559ada6357c982e3dc26aca68
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2015-06-25 18:41:14 +02:00
parent 65343eb283
commit 6aaac9a3b1
10 changed files with 51 additions and 35 deletions

View File

@ -180,10 +180,10 @@ public:
int operator[](uint i) const;
QKeySequence &operator=(const QKeySequence &other);
#ifdef Q_COMPILER_RVALUE_REFS
inline QKeySequence &operator=(QKeySequence &&other)
{ qSwap(d, other.d); return *this; }
QKeySequence &operator=(QKeySequence &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
inline void swap(QKeySequence &other) { qSwap(d, other.d); }
void swap(QKeySequence &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QKeySequence &other) const;
inline bool operator!= (const QKeySequence &other) const
{ return !(*this == other); }

View File

@ -97,14 +97,14 @@ public:
QOpenGLDebugMessage();
QOpenGLDebugMessage(const QOpenGLDebugMessage &debugMessage);
~QOpenGLDebugMessage();
QOpenGLDebugMessage &operator=(const QOpenGLDebugMessage &debugMessage);
#ifdef Q_COMPILER_RVALUE_REFS
inline QOpenGLDebugMessage &operator=(QOpenGLDebugMessage &&debugMessage)
{ d.swap(debugMessage.d); return *this; }
QOpenGLDebugMessage &operator=(QOpenGLDebugMessage &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
inline void swap(QOpenGLDebugMessage &debugMessage) { d.swap(debugMessage.d); }
~QOpenGLDebugMessage();
void swap(QOpenGLDebugMessage &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
Source source() const;
Type type() const;

View File

@ -49,15 +49,14 @@ class Q_GUI_EXPORT QOpenGLPixelTransferOptions
public:
QOpenGLPixelTransferOptions();
QOpenGLPixelTransferOptions(const QOpenGLPixelTransferOptions &);
#ifdef Q_COMPILER_RVALUE_REFS
QOpenGLPixelTransferOptions &operator=(QOpenGLPixelTransferOptions &&other) Q_DECL_NOTHROW
{ swap(other); return *this; }
#endif
QOpenGLPixelTransferOptions &operator=(const QOpenGLPixelTransferOptions &);
~QOpenGLPixelTransferOptions();
#ifdef Q_COMPILER_RVALUE_REFS
QOpenGLPixelTransferOptions &operator=(QOpenGLPixelTransferOptions &&other)
{ swap(other); return *this; }
#endif
void swap(QOpenGLPixelTransferOptions &other)
void swap(QOpenGLPixelTransferOptions &other) Q_DECL_NOTHROW
{ data.swap(other.data); }
void setAlignment(int alignment);

View File

@ -75,14 +75,13 @@ public:
const QMarginsF &margins, Unit units = Point,
const QMarginsF &minMargins = QMarginsF(0, 0, 0, 0));
QPageLayout(const QPageLayout &other);
#ifdef Q_COMPILER_RVALUE_REFS
QPageLayout &operator=(QPageLayout &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
QPageLayout &operator=(const QPageLayout &other);
~QPageLayout();
QPageLayout &operator=(const QPageLayout &other);
#ifdef Q_COMPILER_RVALUE_REFS
QPageLayout &operator=(QPageLayout &&other) { swap(other); return *this; }
#endif
void swap(QPageLayout &other) { d.swap(other.d); }
void swap(QPageLayout &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
friend Q_GUI_EXPORT bool operator==(const QPageLayout &lhs, const QPageLayout &rhs);
bool isEquivalentTo(const QPageLayout &other) const;

View File

@ -229,14 +229,14 @@ public:
const QString &name = QString(),
SizeMatchPolicy matchPolicy = FuzzyMatch);
QPageSize(const QPageSize &other);
#ifdef Q_COMPILER_RVALUE_REFS
QPageSize &operator=(QPageSize &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
QPageSize &operator=(const QPageSize &other);
~QPageSize();
QPageSize &operator=(const QPageSize &other);
#ifdef Q_COMPILER_RVALUE_REFS
QPageSize &operator=(QPageSize &&other) { swap(other); return *this; }
#endif
void swap(QPageSize &other) { d.swap(other.d); }
void swap(QPageSize &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs);
bool isEquivalentTo(const QPageSize &other) const;

View File

@ -56,7 +56,11 @@ public:
inline /*implicit*/ QPolygon(const QVector<QPoint> &v) : QVector<QPoint>(v) {}
QPolygon(const QRect &r, bool closed=false);
QPolygon(int nPoints, const int *points);
inline void swap(QPolygon &other) { QVector<QPoint>::swap(other); } // prevent QVector<QPoint><->QPolygon swaps
#ifdef Q_COMPILER_RVALUE_REFS
QPolygon &operator=(QPolygon &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
QPolygon &operator=(const QPolygon &other) { QVector<QPoint>::operator=(other); return *this; }
void swap(QPolygon &other) Q_DECL_NOTHROW { QVector<QPoint>::swap(other); } // prevent QVector<QPoint><->QPolygon swaps
operator QVariant() const;
@ -130,6 +134,10 @@ public:
inline /*implicit*/ QPolygonF(const QVector<QPointF> &v) : QVector<QPointF>(v) {}
QPolygonF(const QRectF &r);
/*implicit*/ QPolygonF(const QPolygon &a);
#ifdef Q_COMPILER_RVALUE_REFS
QPolygonF &operator=(QPolygonF &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
QPolygonF &operator=(const QPolygonF &other) { QVector<QPointF>::operator=(other); return *this; }
inline void swap(QPolygonF &other) { QVector<QPointF>::swap(other); } // prevent QVector<QPointF><->QPolygonF swaps
operator QVariant() const;

View File

@ -59,9 +59,13 @@ public:
QGlyphRun();
QGlyphRun(const QGlyphRun &other);
#ifdef Q_COMPILER_RVALUE_REFS
QGlyphRun &operator=(QGlyphRun &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
QGlyphRun &operator=(const QGlyphRun &other);
~QGlyphRun();
void swap(QGlyphRun &other) { qSwap(d, other.d); }
void swap(QGlyphRun &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
QRawFont rawFont() const;
void setRawFont(const QRawFont &rawFont);
@ -78,8 +82,6 @@ public:
void clear();
QGlyphRun &operator=(const QGlyphRun &other);
bool operator==(const QGlyphRun &other) const;
inline bool operator!=(const QGlyphRun &other) const
{ return !operator==(other); }

View File

@ -72,14 +72,16 @@ public:
qreal pixelSize,
QFont::HintingPreference hintingPreference = QFont::PreferDefaultHinting);
QRawFont(const QRawFont &other);
#ifdef Q_COMPILER_RVALUE_REFS
QRawFont &operator=(QRawFont &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
QRawFont &operator=(const QRawFont &other);
~QRawFont();
void swap(QRawFont &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool isValid() const;
QRawFont &operator=(const QRawFont &other);
void swap(QRawFont &other) { qSwap(d, other.d); }
bool operator==(const QRawFont &other) const;
inline bool operator!=(const QRawFont &other) const
{ return !operator==(other); }

View File

@ -57,9 +57,13 @@ public:
QStaticText();
QStaticText(const QString &text);
QStaticText(const QStaticText &other);
#ifdef Q_COMPILER_RVALUE_REFS
QStaticText &operator=(QStaticText &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
QStaticText &operator=(const QStaticText &);
~QStaticText();
void swap(QStaticText &other) { qSwap(data, other.data); }
void swap(QStaticText &other) Q_DECL_NOTHROW { qSwap(data, other.data); }
void setText(const QString &text);
QString text() const;
@ -80,7 +84,6 @@ public:
void setPerformanceHint(PerformanceHint performanceHint);
PerformanceHint performanceHint() const;
QStaticText &operator=(const QStaticText &);
bool operator==(const QStaticText &) const;
bool operator!=(const QStaticText &) const;

View File

@ -66,10 +66,13 @@ public:
explicit QTextCursor(const QTextBlock &block);
explicit QTextCursor(QTextCursorPrivate *d);
QTextCursor(const QTextCursor &cursor);
#ifdef Q_COMPILER_RVALUE_REFS
QTextCursor &operator=(QTextCursor &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
QTextCursor &operator=(const QTextCursor &other);
~QTextCursor();
void swap(QTextCursor &other) { qSwap(d, other.d); }
void swap(QTextCursor &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool isNull() const;