diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-09-11 13:37:49 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-09-23 18:00:54 +0200 |
commit | 2f319f3be999eb2462515cfcf2dff505592e73f5 (patch) | |
tree | 0dcff72b3d4ba19ae19a05aca114e95f9da0e4e6 /src/gui/image | |
parent | d3c985631dceef1209c74958baac881d9a67061b (diff) |
Give QPixmap a move constructor
It already has a move-assignment operator, and implements swapping.
This requires a specialization of the QExplicitlySharedDataPointer
destructor to be forward declared, and an implementation that is
identical to the default version. Otherwise we would need
QPlatformPixmap to be fully defined in the public QPixmap header.
Change-Id: I2651bbc29a7083a93e3b3ad671d3aeea659b7d5a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qpixmap.cpp | 9 | ||||
-rw-r--r-- | src/gui/image/qpixmap.h | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 3847366b4d..c3ae853795 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -224,6 +224,15 @@ QPixmap::QPixmap(const QPixmap &pixmap) } } +/*! \fn QPixmap::QPixmap(QPixmap &&other) + Move-constructs a QPixmap instance from \a other. + + \sa swap() operator=(QPixmap&&) +*/ +template<> +QExplicitlySharedDataPointer<QPlatformPixmap>::~QExplicitlySharedDataPointer() +{ if (d && !d->ref.deref()) delete d; } + /*! Constructs a pixmap from the given \a xpm data, which must be a valid XPM image. diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 19881bda2c..b30bef0f6b 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -57,6 +57,7 @@ class QImageReader; class QColor; class QVariant; class QPlatformPixmap; +template<> Q_GUI_EXPORT QExplicitlySharedDataPointer<QPlatformPixmap>::~QExplicitlySharedDataPointer(); class Q_GUI_EXPORT QPixmap : public QPaintDevice { @@ -70,6 +71,7 @@ public: explicit QPixmap(const char * const xpm[]); #endif QPixmap(const QPixmap &); + QPixmap(QPixmap &&other) noexcept : QPaintDevice(), data(std::move(other.data)) {} ~QPixmap(); QPixmap &operator=(const QPixmap &); |