config(Q_NULLPTR),
func(&easeNone)
{ }
+ QEasingCurvePrivate(const QEasingCurvePrivate &other)
+ : type(other.type),
+ config(other.config ? other.config->copy() : Q_NULLPTR),
+ func(other.func)
+ { }
~QEasingCurvePrivate() { delete config; }
void setType_helper(QEasingCurve::Type);
Constructs an easing curve of the given \a type.
*/
QEasingCurve::QEasingCurve(Type type)
- : d_ptr(new QEasingCurvePrivate)
+ : d_ptr(new QEasingCurvePrivate())
{
setType(type);
}
Construct a copy of \a other.
*/
QEasingCurve::QEasingCurve(const QEasingCurve &other)
- : d_ptr(new QEasingCurvePrivate)
+ : d_ptr(new QEasingCurvePrivate(*other.d_ptr))
{
// ### non-atomic, requires malloc on shallow copy
- *d_ptr = *other.d_ptr;
- if (other.d_ptr->config)
- d_ptr->config = other.d_ptr->config->copy();
}
/*!
*/
QEasingCurve &QEasingCurve::operator=(const QEasingCurve &other)
{
- // ### non-atomic, requires malloc on shallow copy
- if (d_ptr->config) {
- delete d_ptr->config;
- d_ptr->config = Q_NULLPTR;
+ if (*this != other) {
+ QEasingCurve copy(other);
+ qSwap(d_ptr, copy.d_ptr);
}
-
- *d_ptr = *other.d_ptr;
- if (other.d_ptr->config)
- d_ptr->config = other.d_ptr->config->copy();
-
return *this;
}
&& d_ptr->type == other.d_ptr->type;
if (res) {
if (d_ptr->config && other.d_ptr->config) {
- // catch the config content
+ // catch the config content
res = d_ptr->config->operator==(*(other.d_ptr->config));
} else if (d_ptr->config || other.d_ptr->config) {
- // one one has a config object, which could contain default values
+ // one one has a config object, which could contain default values
res = qFuzzyCompare(amplitude(), other.amplitude()) &&
qFuzzyCompare(period(), other.period()) &&
qFuzzyCompare(overshoot(), other.overshoot());