QEasingCurve: implement copy assignment operator inline
Implement the copy-assignment operator inline, using the copy-swap idiom. This makes assignment strongly exception safe, but also simplifies maintainence, because op= is formulated in terms of the copy constructor now. Change-Id: I803c9100a520d659b685992237cb76fd114222c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
4fc6bc4804
commit
ca588f40db
@ -1100,22 +1100,9 @@ QEasingCurve::~QEasingCurve()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\fn QEasingCurve &QEasingCurve::operator=(const QEasingCurve &other)
|
||||||
Copy \a other.
|
Copy \a other.
|
||||||
*/
|
*/
|
||||||
QEasingCurve &QEasingCurve::operator=(const QEasingCurve &other)
|
|
||||||
{
|
|
||||||
// ### non-atomic, requires malloc on shallow copy
|
|
||||||
if (d_ptr->config) {
|
|
||||||
delete d_ptr->config;
|
|
||||||
d_ptr->config = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
*d_ptr = *other.d_ptr;
|
|
||||||
if (other.d_ptr->config)
|
|
||||||
d_ptr->config = other.d_ptr->config->copy();
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn void QEasingCurve::swap(QEasingCurve &other)
|
\fn void QEasingCurve::swap(QEasingCurve &other)
|
||||||
|
@ -82,7 +82,8 @@ public:
|
|||||||
QEasingCurve(const QEasingCurve &other);
|
QEasingCurve(const QEasingCurve &other);
|
||||||
~QEasingCurve();
|
~QEasingCurve();
|
||||||
|
|
||||||
QEasingCurve &operator=(const QEasingCurve &other);
|
QEasingCurve &operator=(const QEasingCurve &other)
|
||||||
|
{ if ( this != &other ) { QEasingCurve copy(other); swap(copy); } return *this; }
|
||||||
#ifdef Q_COMPILER_RVALUE_REFS
|
#ifdef Q_COMPILER_RVALUE_REFS
|
||||||
QEasingCurve(QEasingCurve &&other) : d_ptr(other.d_ptr) { other.d_ptr = 0; }
|
QEasingCurve(QEasingCurve &&other) : d_ptr(other.d_ptr) { other.d_ptr = 0; }
|
||||||
QEasingCurve &operator=(QEasingCurve &&other)
|
QEasingCurve &operator=(QEasingCurve &&other)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user