Commit 20477e0a authored by Laszlo Agocs's avatar Laszlo Agocs

Use qAtomic helpers for implicitly shared classes

parent e1fc4c1a
......@@ -2309,20 +2309,15 @@ QRhiShaderResourceBinding::QRhiShaderResourceBinding()
*/
void QRhiShaderResourceBinding::detach()
{
if (d->ref.load() != 1) {
QRhiShaderResourceBindingPrivate *newd = new QRhiShaderResourceBindingPrivate(d);
if (!d->ref.deref())
delete d;
d = newd;
}
qAtomicDetach(d);
}
/*!
\internal
*/
QRhiShaderResourceBinding::QRhiShaderResourceBinding(const QRhiShaderResourceBinding &other)
: d(other.d)
{
d = other.d;
d->ref.ref();
}
......@@ -2331,12 +2326,7 @@ QRhiShaderResourceBinding::QRhiShaderResourceBinding(const QRhiShaderResourceBin
*/
QRhiShaderResourceBinding &QRhiShaderResourceBinding::operator=(const QRhiShaderResourceBinding &other)
{
if (d != other.d) {
other.d->ref.ref();
if (!d->ref.deref())
delete d;
d = other.d;
}
qAtomicAssign(d, other.d);
return *this;
}
......
......@@ -225,20 +225,15 @@ QBakedShader::QBakedShader()
*/
void QBakedShader::detach()
{
if (d->ref.load() != 1) {
QBakedShaderPrivate *newd = new QBakedShaderPrivate(d);
if (!d->ref.deref())
delete d;
d = newd;
}
qAtomicDetach(d);
}
/*!
\internal
*/
QBakedShader::QBakedShader(const QBakedShader &other)
: d(other.d)
{
d = other.d;
d->ref.ref();
}
......@@ -247,12 +242,7 @@ QBakedShader::QBakedShader(const QBakedShader &other)
*/
QBakedShader &QBakedShader::operator=(const QBakedShader &other)
{
if (d != other.d) {
other.d->ref.ref();
if (!d->ref.deref())
delete d;
d = other.d;
}
qAtomicAssign(d, other.d);
return *this;
}
......
......@@ -245,20 +245,15 @@ QShaderDescription::QShaderDescription()
*/
void QShaderDescription::detach()
{
if (d->ref.load() != 1) {
QShaderDescriptionPrivate *newd = new QShaderDescriptionPrivate(d);
if (!d->ref.deref())
delete d;
d = newd;
}
qAtomicDetach(d);
}
/*!
\internal
*/
QShaderDescription::QShaderDescription(const QShaderDescription &other)
: d(other.d)
{
d = other.d;
d->ref.ref();
}
......@@ -267,12 +262,7 @@ QShaderDescription::QShaderDescription(const QShaderDescription &other)
*/
QShaderDescription &QShaderDescription::operator=(const QShaderDescription &other)
{
if (d != other.d) {
other.d->ref.ref();
if (!d->ref.deref())
delete d;
d = other.d;
}
qAtomicAssign(d, other.d);
return *this;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment