summaryrefslogtreecommitdiffstats
path: root/src/opengl/qopenglbuffer.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-07-12 17:55:21 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-07-20 13:15:55 +0200
commitccb2e4dbb18fafb92d1c06a9f2c2ffa862de3abd (patch)
treefaeb49ab4291a226e3f089acc20674de715dd09c /src/opengl/qopenglbuffer.cpp
parent749b2df889ac94c106e59b915ec5862384978878 (diff)
QOpenGLBuffer: add move-SMFs and swap()s
- add move special member functions (docs copied from QHostInfo) - add member swap - use move-and-swap, not pure-swap, because these objects hold resources (handles) other than just memory - Q_DECLARE_SHARED (it's not implicitly shared, but explicitly) - adds ADL swap and Q_DECLARE_TYPEINFO [ChangeLog][QtOpenGL][QOpenGLBuffer] Added member-swap(), move constructor, move assignment operator. Change-Id: I22dc92108bdd393fff4361db23e94eaf3d7ea9cc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/opengl/qopenglbuffer.cpp')
-rw-r--r--src/opengl/qopenglbuffer.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/opengl/qopenglbuffer.cpp b/src/opengl/qopenglbuffer.cpp
index 62d2d5edd2..64e7975043 100644
--- a/src/opengl/qopenglbuffer.cpp
+++ b/src/opengl/qopenglbuffer.cpp
@@ -166,7 +166,7 @@ QOpenGLBuffer::QOpenGLBuffer(const QOpenGLBuffer &other)
*/
QOpenGLBuffer::~QOpenGLBuffer()
{
- if (!d_ptr->ref.deref()) {
+ if (d_ptr && !d_ptr->ref.deref()) {
destroy();
delete d_ptr;
}
@@ -182,7 +182,7 @@ QOpenGLBuffer &QOpenGLBuffer::operator=(const QOpenGLBuffer &other)
{
if (d_ptr != other.d_ptr) {
other.d_ptr->ref.ref();
- if (!d_ptr->ref.deref()) {
+ if (d_ptr && !d_ptr->ref.deref()) {
destroy();
delete d_ptr;
}
@@ -192,6 +192,36 @@ QOpenGLBuffer &QOpenGLBuffer::operator=(const QOpenGLBuffer &other)
}
/*!
+ \fn QOpenGLBuffer::QOpenGLBuffer(QOpenGLBuffer &&other)
+ \since 6.5
+
+ Move-constructs a new QOpenGLBuffer from \a other.
+
+ \note The moved-from object \a other is placed in a partially-formed state,
+ in which the only valid operations are destruction and assignment of a new
+ value.
+*/
+
+/*!
+ \fn QOpenGLBuffer &QOpenGLBuffer::operator=(QOpenGLBuffer &&other)
+ \since 6.5
+
+ Move-assigns \a other to this QOpenGLBuffer instance.
+
+ \note The moved-from object \a other is placed in a partially-formed state,
+ in which the only valid operations are destruction and assignment of a new
+ value.
+*/
+
+/*!
+ \fn QOpenGLBuffer::swap(QOpenGLBuffer &other)
+ \since 6.5
+
+ Swaps buffer \a other with this buffer. This operation is very fast and
+ never fails.
+*/
+
+/*!
Returns the type of buffer represented by this object.
*/
QOpenGLBuffer::Type QOpenGLBuffer::type() const