Add noexcept to move constructors and assignment operators

Add the noexcept attribute to all move constructors and assignment
operators in QtGui that didn't already have it.

Change-Id: Idcdf79ae8349b8793e7394b5ae7c08e6111fbc9a
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
Allan Sandfeld Jensen 2015-04-21 16:25:25 +02:00
parent eb82959d66
commit e445f3c47b
16 changed files with 47 additions and 35 deletions

View File

@ -606,7 +606,7 @@ QFactoryLoader *qt_iconEngineFactoryLoader()
/*!
Constructs a null icon.
*/
QIcon::QIcon()
QIcon::QIcon() Q_DECL_NOEXCEPT
: d(0)
{
}

View File

@ -51,22 +51,24 @@ public:
enum Mode { Normal, Disabled, Active, Selected };
enum State { On, Off };
QIcon();
QIcon() Q_DECL_NOEXCEPT;
QIcon(const QPixmap &pixmap);
QIcon(const QIcon &other);
#ifdef Q_COMPILER_RVALUE_REFS
QIcon(QIcon &&other)
:d(0) { qSwap(d, other.d); }
QIcon(QIcon &&other) Q_DECL_NOEXCEPT
: d(0)
{ qSwap(d, other.d); }
#endif
explicit QIcon(const QString &fileName); // file or resource name
explicit QIcon(QIconEngine *engine);
~QIcon();
QIcon &operator=(const QIcon &other);
#ifdef Q_COMPILER_RVALUE_REFS
inline QIcon &operator=(QIcon &&other)
inline QIcon &operator=(QIcon &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
inline void swap(QIcon &other) { qSwap(d, other.d); }
inline void swap(QIcon &other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); }
operator QVariant() const;

View File

@ -734,7 +734,7 @@ bool QImageData::checkForAlphaPixels() const
\sa isNull()
*/
QImage::QImage()
QImage::QImage() Q_DECL_NOEXCEPT
: QPaintDevice()
{
d = 0;

View File

@ -121,7 +121,7 @@ public:
#endif
};
QImage();
QImage() Q_DECL_NOEXCEPT;
QImage(const QSize &size, Format format);
QImage(int width, int height, Format format);
QImage(uchar *data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = 0, void *cleanupInfo = 0);
@ -136,7 +136,7 @@ public:
QImage(const QImage &);
#ifdef Q_COMPILER_RVALUE_REFS
inline QImage(QImage &&other)
inline QImage(QImage &&other) Q_DECL_NOEXCEPT
: QPaintDevice(), d(0)
{ qSwap(d, other.d); }
#endif
@ -144,10 +144,11 @@ public:
QImage &operator=(const QImage &);
#ifdef Q_COMPILER_RVALUE_REFS
inline QImage &operator=(QImage &&other)
inline QImage &operator=(QImage &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
inline void swap(QImage &other) { qSwap(d, other.d); }
inline void swap(QImage &other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); }
bool isNull() const;

View File

@ -72,10 +72,11 @@ public:
QPicture& operator=(const QPicture &p);
#ifdef Q_COMPILER_RVALUE_REFS
inline QPicture &operator=(QPicture &&other)
inline QPicture &operator=(QPicture &&other) Q_DECL_NOEXCEPT
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
inline void swap(QPicture &other) { d_ptr.swap(other.d_ptr); }
inline void swap(QPicture &other) Q_DECL_NOEXCEPT
{ d_ptr.swap(other.d_ptr); }
void detach();
bool isDetached() const;

View File

@ -67,10 +67,11 @@ public:
QPixmap &operator=(const QPixmap &);
#ifdef Q_COMPILER_RVALUE_REFS
inline QPixmap &operator=(QPixmap &&other)
inline QPixmap &operator=(QPixmap &&other) Q_DECL_NOEXCEPT
{ qSwap(data, other.data); return *this; }
#endif
inline void swap(QPixmap &other) { qSwap(data, other.data); }
inline void swap(QPixmap &other) Q_DECL_NOEXCEPT
{ qSwap(data, other.data); }
operator QVariant() const;

View File

@ -789,8 +789,10 @@ public:
explicit TouchPoint(int id = -1);
TouchPoint(const TouchPoint &other);
#ifdef Q_COMPILER_RVALUE_REFS
TouchPoint(TouchPoint &&other) : d(other.d) { other.d = 0; }
TouchPoint &operator=(TouchPoint &&other)
TouchPoint(TouchPoint &&other) Q_DECL_NOEXCEPT
: d(0)
{ qSwap(d, other.d); }
TouchPoint &operator=(TouchPoint &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
~TouchPoint();
@ -798,7 +800,8 @@ public:
TouchPoint &operator=(const TouchPoint &other)
{ if ( d != other.d ) { TouchPoint copy(other); swap(copy); } return *this; }
void swap(TouchPoint &other) { qSwap(d, other.d); }
void swap(TouchPoint &other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); }
int id() const;

View File

@ -61,16 +61,18 @@ public:
~QPalette();
QPalette &operator=(const QPalette &palette);
#ifdef Q_COMPILER_RVALUE_REFS
QPalette(QPalette &&other) Q_DECL_NOTHROW
: d(other.d), data(other.data) { other.d = Q_NULLPTR; }
inline QPalette &operator=(QPalette &&other)
QPalette(QPalette &&other) Q_DECL_NOEXCEPT
: d(other.d), data(other.data)
{ other.d = Q_NULLPTR; }
inline QPalette &operator=(QPalette &&other) Q_DECL_NOEXCEPT
{
for_faster_swapping_dont_use = other.for_faster_swapping_dont_use;
qSwap(d, other.d); return *this;
}
#endif
void swap(QPalette &other) {
void swap(QPalette &other) Q_DECL_NOEXCEPT
{
qSwap(d, other.d);
qSwap(for_faster_swapping_dont_use, other.for_faster_swapping_dont_use);
}

View File

@ -73,10 +73,11 @@ public:
~QBrush();
QBrush &operator=(const QBrush &brush);
#ifdef Q_COMPILER_RVALUE_REFS
inline QBrush &operator=(QBrush &&other)
inline QBrush &operator=(QBrush &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
inline void swap(QBrush &other) { qSwap(d, other.d); }
inline void swap(QBrush &other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); }
operator QVariant() const;

View File

@ -35,7 +35,7 @@
QT_BEGIN_NAMESPACE
QPaintDevice::QPaintDevice()
QPaintDevice::QPaintDevice() Q_DECL_NOEXCEPT
{
reserved = 0;
painters = 0;

View File

@ -80,7 +80,7 @@ public:
int depth() const { return metric(PdmDepth); }
protected:
QPaintDevice();
QPaintDevice() Q_DECL_NOEXCEPT;
virtual int metric(PaintDeviceMetric metric) const;
virtual void initPainter(QPainter *painter) const;
virtual QPaintDevice *redirected(QPoint *offset) const;

View File

@ -521,7 +521,7 @@ void QPainterPath::setElementPositionAt(int i, qreal x, qreal y)
/*!
Constructs an empty QPainterPath object.
*/
QPainterPath::QPainterPath()
QPainterPath::QPainterPath() Q_DECL_NOEXCEPT
: d_ptr(0)
{
}

View File

@ -81,16 +81,16 @@ public:
inline bool operator!=(const Element &e) const { return !operator==(e); }
};
QPainterPath();
QPainterPath() Q_DECL_NOEXCEPT;
explicit QPainterPath(const QPointF &startPoint);
QPainterPath(const QPainterPath &other);
QPainterPath &operator=(const QPainterPath &other);
#ifdef Q_COMPILER_RVALUE_REFS
inline QPainterPath &operator=(QPainterPath &&other)
inline QPainterPath &operator=(QPainterPath &&other) Q_DECL_NOEXCEPT
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
~QPainterPath();
inline void swap(QPainterPath &other) { d_ptr.swap(other.d_ptr); }
inline void swap(QPainterPath &other) Q_DECL_NOEXCEPT { d_ptr.swap(other.d_ptr); }
void closeSubpath();

View File

@ -66,10 +66,10 @@ public:
~QRegion();
QRegion &operator=(const QRegion &);
#ifdef Q_COMPILER_RVALUE_REFS
inline QRegion &operator=(QRegion &&other)
inline QRegion &operator=(QRegion &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
inline void swap(QRegion &other) { qSwap(d, other.d); }
inline void swap(QRegion &other) Q_DECL_NOEXCEPT { qSwap(d, other.d); }
bool isEmpty() const;
bool isNull() const;

View File

@ -237,7 +237,7 @@ public:
operator QVariant() const;
bool isCopyOf(const QFont &) const;
#ifdef Q_COMPILER_RVALUE_REFS
inline QFont &operator=(QFont &&other)
inline QFont &operator=(QFont &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); qSwap(resolve_mask, other.resolve_mask); return *this; }
#endif

View File

@ -58,11 +58,12 @@ public:
QFontMetrics &operator=(const QFontMetrics &);
#ifdef Q_COMPILER_RVALUE_REFS
inline QFontMetrics &operator=(QFontMetrics &&other)
inline QFontMetrics &operator=(QFontMetrics &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
void swap(QFontMetrics &other) { qSwap(d, other.d); }
void swap(QFontMetrics &other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); }
int ascent() const;
int descent() const;