From d04a191e0284d9260ba8e0a12ed42038bef05a8b Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 10 Oct 2011 16:29:11 +0200 Subject: Use QBasicAtomicInt load() and store() instead of implicit casting The implicit casts will be unavailable in the near future. Change-Id: I7305bed90fdcd50e910b207dc41caa8d34467c54 Reviewed-on: http://codereview.qt-project.org/6352 Sanity-Review: Qt Sanity Bot Reviewed-by: Lars Knoll --- src/script/api/qscriptstring.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/script/api/qscriptstring.cpp') diff --git a/src/script/api/qscriptstring.cpp b/src/script/api/qscriptstring.cpp index 2930c9e..16e9096 100644 --- a/src/script/api/qscriptstring.cpp +++ b/src/script/api/qscriptstring.cpp @@ -71,9 +71,9 @@ QScriptString::QScriptString(const QScriptString &other) : d_ptr(other.d_ptr) { if (d_func() && (d_func()->type == QScriptStringPrivate::StackAllocated)) { - Q_ASSERT(d_func()->ref != 1); + Q_ASSERT(d_func()->ref.load() != 1); d_ptr.detach(); - d_func()->ref = 1; + d_func()->ref.store(1); d_func()->type = QScriptStringPrivate::HeapAllocated; d_func()->engine->registerScriptString(d_func()); } @@ -88,11 +88,11 @@ QScriptString::~QScriptString() if (d) { switch (d->type) { case QScriptStringPrivate::StackAllocated: - Q_ASSERT(d->ref == 1); + Q_ASSERT(d->ref.load() == 1); d->ref.ref(); // avoid deletion break; case QScriptStringPrivate::HeapAllocated: - if (d->engine && (d->ref == 1)) { + if (d->engine && (d->ref.load() == 1)) { // Make sure the identifier is removed from the correct engine. QScript::APIShim shim(d->engine); d->identifier = JSC::Identifier(); @@ -108,15 +108,15 @@ QScriptString::~QScriptString() */ QScriptString &QScriptString::operator=(const QScriptString &other) { - if (d_func() && d_func()->engine && (d_func()->ref == 1) && (d_func()->type == QScriptStringPrivate::HeapAllocated)) { + if (d_func() && d_func()->engine && (d_func()->ref.load() == 1) && (d_func()->type == QScriptStringPrivate::HeapAllocated)) { // current d_ptr will be deleted at the assignment below, so unregister it first d_func()->engine->unregisterScriptString(d_func()); } d_ptr = other.d_ptr; if (d_func() && (d_func()->type == QScriptStringPrivate::StackAllocated)) { - Q_ASSERT(d_func()->ref != 1); + Q_ASSERT(d_func()->ref.load() != 1); d_ptr.detach(); - d_func()->ref = 1; + d_func()->ref.store(1); d_func()->type = QScriptStringPrivate::HeapAllocated; d_func()->engine->registerScriptString(d_func()); } -- cgit v1.2.1