summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qpalette.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-07-25 23:17:55 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-08-06 13:52:24 +0200
commitde8a9dee5aa7c8db3b390c9a19f65c919d201c3c (patch)
tree7e141452814d2c38e932d571a63d2d0b0e5e6697 /src/gui/kernel/qpalette.cpp
parentfa31f9761ac378807747a19589b7476546e4fae4 (diff)
QPalette: add move constructor
As with many other implicitly shared classes, efficient move semantics requires setting the d-pointer to nullptr, which then needs to be checked for in the dtor and the copy assignment operator. Change-Id: I654d181a1dfdd9a16e2f9fb96b57475cdd0b4561 Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/gui/kernel/qpalette.cpp')
-rw-r--r--src/gui/kernel/qpalette.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 62e555b821..52b0372ea8 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -643,11 +643,22 @@ QPalette::QPalette(const QPalette &p)
}
/*!
+ \fn QPalette::QPalette(QPalette &&other)
+ \since 5.4
+
+ Move-constructs a QPalette instance, making it point at the same
+ object that \a other was pointing to.
+
+ After being moved from, you can only assign to or destroy \a other.
+ Any other operation will result in undefined behavior.
+*/
+
+/*!
Destroys the palette.
*/
QPalette::~QPalette()
{
- if(!d->ref.deref())
+ if (d && !d->ref.deref())
delete d;
}
@@ -668,7 +679,7 @@ QPalette &QPalette::operator=(const QPalette &p)
{
p.d->ref.ref();
data = p.data;
- if(!d->ref.deref())
+ if (d && !d->ref.deref())
delete d;
d = p.d;
return *this;