bool QFutureInterfaceBase::referenceCountIsOne() const
{
- return d->refCount == 1;
+ return d->refCount.load() == 1;
}
QFutureInterfaceBasePrivate::QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState)
emit q->resultsReadyAt(beginIndex, endIndex);
- if (int(resultAtConnected) <= 0)
+ if (resultAtConnected.load() <= 0)
break;
for (int i = beginIndex; i < endIndex; ++i)
bool shouldStartThread()
{
if (forIteration)
- return (currentIndex < iterationCount) && !this->shouldThrottleThread();
+ return (currentIndex.load() < iterationCount) && !this->shouldThrottleThread();
else // whileIteration
- return (iteratorThreads == 0);
+ return (iteratorThreads.load() == 0);
}
ThreadFunctionResult threadFunction()
const int currentBlockSize = blockSizeManager.blockSize();
- if (currentIndex >= iterationCount)
+ if (currentIndex.load() >= iterationCount)
break;
// Atomically reserve a block of iterationCount for this thread.
// Report progress if progress reporting enabled.
if (progressReportingEnabled) {
completed.fetchAndAddAcquire(finalBlockSize);
- this->setProgressValue(this->completed);
+ this->setProgressValue(this->completed.load());
}
if (this->shouldThrottleThread())
void ThreadEngineBarrier::acquire()
{
forever {
- int localCount = int(count);
+ int localCount = count.load();
if (localCount < 0) {
if (count.testAndSetOrdered(localCount, localCount -1))
return;
int ThreadEngineBarrier::release()
{
forever {
- int localCount = int(count);
+ int localCount = count.load();
if (localCount == -1) {
if (count.testAndSetOrdered(-1, 0)) {
semaphore.release();
void ThreadEngineBarrier::wait()
{
forever {
- int localCount = int(count);
+ int localCount = count.load();
if (localCount == 0)
return;
int ThreadEngineBarrier::currentCount()
{
- return int(count);
+ return count.load();
}
// releases a thread, unless this is the last thread.
bool ThreadEngineBarrier::releaseUnlessLast()
{
forever {
- int localCount = int(count);
+ int localCount = count.load();
if (qAbs(localCount) == 1) {
return false;
} else if (localCount < 0) {
template<> Q_INLINE_TEMPLATE void QSharedDataPointer<QProcessEnvironmentPrivate>::detach()
{
- if (d && d->ref == 1)
+ if (d && d->ref.load() == 1)
return;
QProcessEnvironmentPrivate *x = (d ? new QProcessEnvironmentPrivate(*d)
: new QProcessEnvironmentPrivate);
*/
bool QUrl::isDetached() const
{
- return !d || d->ref == 1;
+ return !d || d->ref.load() == 1;
}
void QPersistentModelIndexData::destroy(QPersistentModelIndexData *data)
{
Q_ASSERT(data);
- Q_ASSERT(data->ref == 0);
+ Q_ASSERT(data->ref.load() == 0);
QAbstractItemModel *model = const_cast<QAbstractItemModel *>(data->model);
// a valid persistent model index with a null model pointer can only happen if the model was destroyed
if (model) {
QObjectPrivate::clearGuards(this);
}
- if (d->sharedRefcount) {
- if (d->sharedRefcount->strongref.load() > 0) {
+ QtSharedPointer::ExternalRefCountData *sharedRefcount = d->sharedRefcount.load();
+ if (sharedRefcount) {
+ if (sharedRefcount->strongref.load() > 0) {
qWarning("QObject: shared QObject was deleted directly. The program is malformed and may crash.");
// but continue deleting, it's too late to stop anyway
}
// indicate to all QWeakPointers that this QObject has now been deleted
- d->sharedRefcount->strongref.store(0);
- if (!d->sharedRefcount->weakref.deref())
- delete d->sharedRefcount;
+ sharedRefcount->strongref.store(0);
+ if (!sharedRefcount->weakref.deref())
+ delete sharedRefcount;
}
-
if (d->isSignalConnected(0)) {
QT_TRY {
emit destroyed(this);
void QVariant::detach()
{
- if (!d.is_shared || d.data.shared->ref == 1)
+ if (!d.is_shared || d.data.shared->ref.load() == 1)
return;
Private dd;
#endif
inline bool QVariant::isDetached() const
-{ return !d.is_shared || d.data.shared->ref == 1; }
+{ return !d.is_shared || d.data.shared->ref.load() == 1; }
#ifdef qdoc
template <typename T>
inline void qAtomicDetach(T *&d)
{
- if (d->ref == 1)
+ if (d->ref.load() == 1)
return;
T *x = d;
d = new T(*d);
delete static_cast<QRecursiveMutexPrivate *>(d.load());
else if (d.load()) {
#ifndef Q_OS_LINUX
- if (d.load()->possiblyUnlocked && tryLock()) { unlock(); return; }
+ if (d.load()->possiblyUnlocked.load() && tryLock()) { unlock(); return; }
#endif
qWarning("QMutex: destroying locked mutex");
}
return static_cast<QRecursiveMutexPrivate *>(d)->lock(timeout);
}
- if (timeout == 0 && !d->possiblyUnlocked)
+ if (timeout == 0 && !d->possiblyUnlocked.load())
return false;
if (!d->ref())
int old_waiters;
do {
- old_waiters = d->waiters;
+ old_waiters = d->waiters.load();
if (old_waiters == -QMutexPrivate::BigNumber) {
// we are unlocking, and the thread that unlocks is about to change d to 0
// we try to aquire the mutex by changing to dummyLocked()
}
if (d->wait(timeout)) {
- if (d->possiblyUnlocked && d->possiblyUnlocked.testAndSetRelaxed(true, false))
+ if (d->possiblyUnlocked.load() && d->possiblyUnlocked.testAndSetRelaxed(true, false))
d->deref();
d->derefWaiters(1);
//we got the lock. (do not deref)
if (d->waiters.fetchAndAddRelease(-QMutexPrivate::BigNumber) == 0) {
//there is no one waiting on this mutex anymore, set the mutex as unlocked (d = 0)
if (this->d.testAndSetRelease(d, 0)) {
- if (d->possiblyUnlocked && d->possiblyUnlocked.testAndSetRelaxed(true, false))
+ if (d->possiblyUnlocked.load() && d->possiblyUnlocked.testAndSetRelaxed(true, false))
d->deref();
}
d->derefWaiters(0);
int i = freelist()->next();
QMutexPrivate *d = &(*freelist())[i];
d->id = i;
- Q_ASSERT(d->refCount == 0);
+ Q_ASSERT(d->refCount.load() == 0);
Q_ASSERT(!d->recursive);
- Q_ASSERT(!d->possiblyUnlocked);
- Q_ASSERT(d->waiters == 0);
+ Q_ASSERT(!d->possiblyUnlocked.load());
+ Q_ASSERT(d->waiters.load() == 0);
d->refCount = 1;
return d;
}
void QMutexPrivate::release()
{
Q_ASSERT(!recursive);
- Q_ASSERT(refCount == 0);
- Q_ASSERT(!possiblyUnlocked);
- Q_ASSERT(waiters == 0);
+ Q_ASSERT(refCount.load() == 0);
+ Q_ASSERT(!possiblyUnlocked.load());
+ Q_ASSERT(waiters.load() == 0);
freelist()->release(id);
}
int old_waiters;
int new_waiters;
do {
- old_waiters = waiters;
+ old_waiters = waiters.load();
new_waiters = old_waiters;
if (new_waiters < 0) {
new_waiters += QMutexPrivate::BigNumber;
int id;
bool ref() {
- Q_ASSERT(refCount >= 0);
+ Q_ASSERT(refCount.load() >= 0);
int c;
do {
- c = refCount;
+ c = refCount.load();
if (c == 0)
return false;
} while (!refCount.testAndSetRelaxed(c, c + 1));
- Q_ASSERT(refCount >= 0);
+ Q_ASSERT(refCount.load() >= 0);
return true;
}
void deref() {
- Q_ASSERT(refCount >=0);
+ Q_ASSERT(refCount.load() >= 0);
if (!refCount.deref())
release();
- Q_ASSERT(refCount >=0);
+ Q_ASSERT(refCount.load() >= 0);
}
void release();
static QMutexPrivate *allocate();
: mutexes(size), recursionMode(recursionMode)
{
for (int index = 0; index < mutexes.count(); ++index) {
- mutexes[index] = 0;
+ mutexes[index].store(0);
}
}
*/
QMutexPool::~QMutexPool()
{
- for (int index = 0; index < mutexes.count(); ++index) {
- delete mutexes[index];
- mutexes[index] = 0;
- }
+ for (int index = 0; index < mutexes.count(); ++index)
+ delete mutexes[index].load();
}
/*!
{
// mutex not created, create one
QMutex *newMutex = new QMutex(recursionMode);
- if (!mutexes[index].testAndSetOrdered(0, newMutex))
+ if (!mutexes[index].testAndSetRelease(0, newMutex))
delete newMutex;
- return mutexes[index];
+ return mutexes[index].load();
}
/*!
inline QMutex *get(const void *address) {
int index = uint(quintptr(address)) % mutexes.count();
- QMutex *m = mutexes[index];
+ QMutex *m = mutexes[index].load();
if (m)
return m;
else
QThreadData::~QThreadData()
{
- Q_ASSERT(_ref == 0);
+ Q_ASSERT(_ref.load() == 0);
// In the odd case that Qt is running on a secondary thread, the main
// thread instance will have been dereffed asunder because of the deref in
{
#ifndef QT_NO_THREAD
(void) _ref.ref();
- Q_ASSERT(_ref != 0);
+ Q_ASSERT(_ref.load() != 0);
#endif
}
void QRegExpEngine::setup()
{
- ref = 1;
+ ref.store(1);
#ifndef QT_NO_REGEXP_CAPTURE
f.resize(32);
nf = 0;
Q_ASSERT(obj);
QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject *>(obj));
- if (d->sharedRefcount)
+ if (d->sharedRefcount.load() != 0)
qFatal("QSharedPointer: pointer %p already has reference counting", obj);
- d->sharedRefcount = this;
+ d->sharedRefcount.store(this);
// QObject decreases the refcount too, so increase it up
weakref.ref();
QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject *>(obj));
Q_ASSERT_X(!d->wasDeleted, "QWeakPointer", "Detected QWeakPointer creation in a QObject being deleted");
- ExternalRefCountData *that = d->sharedRefcount;
+ ExternalRefCountData *that = d->sharedRefcount.load();
if (that) {
that->weakref.ref();
return that;
x->weakref.store(2); // the QWeakPointer that called us plus the QObject itself
if (!d->sharedRefcount.testAndSetRelease(0, x)) {
delete x;
- d->sharedRefcount->weakref.ref();
+ x = d->sharedRefcount.loadAcquire();
+ x->weakref.ref();
}
- return d->sharedRefcount.loadAcquire();
+ return x;
}
QT_END_NAMESPACE
void QImage::detach()
{
if (d) {
- if (d->is_cached && d->ref == 1)
+ if (d->is_cached && d->ref.load() == 1)
QImagePixmapCleanupHooks::executeImageHooks(cacheKey());
- if (d->ref != 1 || d->ro_data)
+ if (d->ref.load() != 1 || d->ro_data)
*this = copy();
if (d)
bool QImage::isDetached() const
{
- return d && d->ref == 1;
+ return d && d->ref.load() == 1;
}
return true;
// No in-place conversion if we have to detach
- if (ref > 1)
+ if (ref.load() > 1)
return false;
const InPlace_Image_Converter *const converterPtr = &inplace_converter_map[format][newFormat];
bool QPicture::isDetached() const
{
- return d_func()->ref == 1;
+ return d_func()->ref.load() == 1;
}
/*!
QPixmap::~QPixmap()
{
- Q_ASSERT(!data || data->ref >= 1); // Catch if ref-counting changes again
+ Q_ASSERT(!data || data->ref.load() >= 1); // Catch if ref-counting changes again
}
/*!
return;
}
- if (data->ref == 1) {
+ if (data->ref.load() == 1) {
// detach() will also remove this pixmap from caches, so
// it has to be called even when ref == 1.
detach();
bool QPixmap::isDetached() const
{
- return data && data->ref == 1;
+ return data && data->ref.load() == 1;
}
/*! \internal
rasterData->image.detach();
}
- if (data->is_cached && data->ref == 1)
+ if (data->is_cached && data->ref.load() == 1)
QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(data.data());
- if (data->ref != 1) {
+ if (data->ref.load() != 1) {
*this = copy();
}
++data->detach_no;
/*! \internal */
void QTouchEvent::TouchPoint::setId(int id)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->id = id;
}
/*! \internal */
void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->state = state;
}
/*! \internal */
void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->rect.moveCenter(pos);
}
/*! \internal */
void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->sceneRect.moveCenter(scenePos);
}
/*! \internal */
void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->screenRect.moveCenter(screenPos);
}
/*! \internal */
void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->normalizedPos = normalizedPos;
}
/*! \internal */
void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->startPos = startPos;
}
/*! \internal */
void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->startScenePos = startScenePos;
}
/*! \internal */
void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->startScreenPos = startScreenPos;
}
/*! \internal */
void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->startNormalizedPos = startNormalizedPos;
}
/*! \internal */
void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->lastPos = lastPos;
}
/*! \internal */
void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->lastScenePos = lastScenePos;
}
/*! \internal */
void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->lastScreenPos = lastScreenPos;
}
/*! \internal */
void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->lastNormalizedPos = lastNormalizedPos;
}
/*! \internal */
void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->rect = rect;
}
/*! \internal */
void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->sceneRect = sceneRect;
}
/*! \internal */
void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->screenRect = screenRect;
}
/*! \internal */
void QTouchEvent::TouchPoint::setPressure(qreal pressure)
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d = d->detach();
d->pressure = pressure;
}
*/
bool QKeySequence::isDetached() const
{
- return d->ref == 1;
+ return d->ref.load() == 1;
}
/*!
active.deref();
}
#ifndef QT_NO_DEBUG
- if (active != 0) {
+ if (active.load() != 0) {
qWarning("QtGui: Resources are still available at program shutdown.\n"
" This is possibly caused by a leaked QOpenGLWidget, \n"
" QOpenGLFramebufferObject or QOpenGLPixelBuffer.");
*/
void QPalette::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QPalettePrivate *x = new QPalettePrivate;
for(int grp = 0; grp < (int)NColorGroups; grp++) {
for(int role = 0; role < (int)NColorRoles; role++)
*/
void QSurfaceFormat::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QSurfaceFormatPrivate *newd = new QSurfaceFormatPrivate(d);
if (!d->ref.deref())
delete d;
*/
void QOpenGLFramebufferObjectFormat::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QOpenGLFramebufferObjectFormatPrivate *newd
= new QOpenGLFramebufferObjectFormatPrivate(d);
if (!d->ref.deref())
QBrushData *brush;
QNullBrushData() : brush(new QBrushData)
{
- brush->ref = 1;
+ brush->ref.store(1);
brush->style = Qt::BrushStyle(0);
brush->color = Qt::black;
}
d.reset(new QBrushData);
break;
}
- d->ref = 1;
+ d->ref.store(1);
d->style = style;
d->color = color;
}
void QBrush::detach(Qt::BrushStyle newStyle)
{
- if (newStyle == d->style && d->ref == 1)
+ if (newStyle == d->style && d->ref.load() == 1)
return;
QScopedPointer<QBrushData> x;
x.reset(new QBrushData);
break;
}
- x->ref = 1;
+ x->ref.store(1);
x->style = newStyle;
x->color = d->color;
x->transform = d->transform;
inline const QColor &QBrush::color() const { return d->color; }
inline const QMatrix &QBrush::matrix() const { return d->transform.toAffine(); }
inline QTransform QBrush::transform() const { return d->transform; }
-inline bool QBrush::isDetached() const { return d->ref == 1; }
+inline bool QBrush::isDetached() const { return d->ref.load() == 1; }
/*******************************************************************************
inline void QPainterPath::detach()
{
- if (d_ptr->ref != 1)
+ if (d_ptr->ref.load() != 1)
detach_helper();
setDirty(true);
}
inline void QPainterPathData::close()
{
- Q_ASSERT(ref == 1);
+ Q_ASSERT(ref.load() == 1);
require_moveTo = true;
const QPainterPath::Element &first = elements.at(cStart);
QPainterPath::Element &last = elements.last();
*/
inline QPenPrivate::QPenPrivate(const QBrush &_brush, qreal _width, Qt::PenStyle penStyle,
Qt::PenCapStyle _capStyle, Qt::PenJoinStyle _joinStyle)
- : dashOffset(0), miterLimit(2),
+ : ref(1), dashOffset(0), miterLimit(2),
cosmetic(false)
{
- ref = 1;
width = _width;
brush = _brush;
style = penStyle;
void QPen::detach()
{
- if (d->ref == 1)
+ if (d->ref.load() == 1)
return;
QPenData *x = new QPenData(*static_cast<QPenData *>(d));
bool QPen::isDetached()
{
- return d->ref == 1;
+ return d->ref.load() == 1;
}
*/
void QFont::detach()
{
- if (d->ref == 1) {
+ if (d->ref.load() == 1) {
if (d->engineData)
d->engineData->ref.deref();
d->engineData = 0;
EngineDataCache::ConstIterator it = engineDataCache.constBegin(),
end = engineDataCache.constEnd();
while (it != end) {
- if (it.value()->ref == 0)
+ if (it.value()->ref.load() == 0)
delete it.value();
else
FC_DEBUG("QFontCache::~QFontCache: engineData %p still has refcount %d",
- it.value(), int(it.value()->ref));
+ it.value(), it.value()->ref.load());
++it;
}
}
end = engineCache.constEnd();
while (it != end) {
if (--it.value().data->cache_count == 0) {
- if (it.value().data->ref == 0) {
+ if (it.value().data->ref.load() == 0) {
FC_DEBUG("QFontCache::~QFontCache: deleting engine %p key=(%d / %g %g %d %d %d)",
it.value().data, it.key().script, it.key().def.pointSize,
it.key().def.pixelSize, it.key().def.weight, it.key().def.style,
delete it.value().data;
} else {
FC_DEBUG("QFontCache::~QFontCache: engine = %p still has refcount %d",
- it.value().data, int(it.value().data->ref));
+ it.value().data, it.value().data->ref.load());
}
}
++it;
for (EngineCache::Iterator it = engineCache.begin(), end = engineCache.end();
it != end; ++it) {
- if (it->data->ref == 0) {
+ if (it->data->ref.load() == 0) {
delete it->data;
it->data = 0;
}
for (EngineCache::Iterator it = engineCache.begin(), end = engineCache.end();
it != end; ++it) {
- if (it->data && it->data->ref == 0) {
+ if (it->data && it->data->ref.load() == 0) {
delete it->data;
it->data = 0;
}
FC_DEBUG("QFontCache: found font engine\n"
" %p: timestamp %4u hits %3u ref %2d/%2d, type '%s'",
it.value().data, it.value().timestamp, it.value().hits,
- int(it.value().data->ref), it.value().data->cache_count,
+ it.value().data->ref.load(), it.value().data->cache_count,
it.value().data->name());
return it.value().data;
cost, total_cost, max_cost);
}
-
void QFontCache::timerEvent(QTimerEvent *)
{
FC_DEBUG("QFontCache::timerEvent: performing cache maintenance (timestamp %u)",
#endif // QFONTCACHE_DEBUG
- if (it.value()->ref != 0)
+ if (it.value()->ref.load() != 0)
in_use_cost += engine_data_cost;
}
}
for (; it != end; ++it) {
FC_DEBUG(" %p: timestamp %4u hits %2u ref %2d/%2d, cost %u bytes",
it.value().data, it.value().timestamp, it.value().hits,
- int(it.value().data->ref), it.value().data->cache_count,
+ it.value().data->ref.load(), it.value().data->cache_count,
it.value().data->cache_cost);
- if (it.value().data->ref != 0)
+ if (it.value().data->ref.load() != 0)
in_use_cost += it.value().data->cache_cost / it.value().data->cache_count;
}
EngineDataCache::Iterator it = engineDataCache.begin(),
end = engineDataCache.end();
while (it != end) {
- if (it.value()->ref != 0) {
+ if (it.value()->ref.load() != 0) {
++it;
continue;
}
uint least_popular = ~0u;
for (; it != end; ++it) {
- if (it.value().data->ref != 0)
+ if (it.value().data->ref.load() != 0)
continue;
if (it.value().timestamp < oldest &&
FC_DEBUG(" oldest %u least popular %u", oldest, least_popular);
for (it = engineCache.begin(); it != end; ++it) {
- if (it.value().data->ref == 0 &&
+ if (it.value().data->ref.load() == 0 &&
it.value().timestamp == oldest &&
it.value().hits == least_popular)
break;
if (it != end) {
FC_DEBUG(" %p: timestamp %4u hits %2u ref %2d/%2d, type '%s'",
it.value().data, it.value().timestamp, it.value().hits,
- int(it.value().data->ref), it.value().data->cache_count,
+ it.value().data->ref.load(), it.value().data->cache_count,
it.value().data->name());
if (--it.value().data->cache_count == 0) {
// QFontEngine
QFontEngine::QFontEngine()
- : QObject()
+ : QObject(), ref(0)
{
- ref = 0;
cache_count = 0;
fsType = 0;
symbol = false;
QFontEngine *fontEngine = engines.at(i);
if (fontEngine) {
fontEngine->ref.deref();
- if (fontEngine->cache_count == 0 && fontEngine->ref == 0)
+ if (fontEngine->cache_count == 0 && fontEngine->ref.load() == 0)
delete fontEngine;
}
}
*/
void QGlyphRun::detach()
{
- if (d->ref != 1)
+ if (d->ref.load() != 1)
d.detach();
}
*/
void QSupportedWritingSystems::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QWritingSystemsPrivate *newd = new QWritingSystemsPrivate(d);
if (!d->ref.deref())
delete d;
d->fontEngine->ref.ref();
oldFontEngine->ref.deref();
- if (oldFontEngine->cache_count == 0 && oldFontEngine->ref == 0)
+ if (oldFontEngine->cache_count == 0 && oldFontEngine->ref.load() == 0)
delete oldFontEngine;
}
platformCleanUp();
if (fontEngine != 0) {
fontEngine->ref.deref();
- if (fontEngine->cache_count == 0 && fontEngine->ref == 0)
+ if (fontEngine->cache_count == 0 && fontEngine->ref.load() == 0)
delete fontEngine;
fontEngine = 0;
}
~QRawFontPrivate()
{
- Q_ASSERT(ref == 0);
+ Q_ASSERT(ref.load() == 0);
cleanUp();
}
*/
QStaticText::~QStaticText()
{
- Q_ASSERT(!data || data->ref >= 1);
+ Q_ASSERT(!data || data->ref.load() >= 1);
}
/*!
*/
void QStaticText::detach()
{
- if (data->ref != 1)
+ if (data->ref.load() != 1)
data.detach();
}
{
if (fontEngine) {
fontEngine->ref.deref();
- if (fontEngine->cache_count == 0 && fontEngine->ref == 0)
+ if (fontEngine->cache_count == 0 && fontEngine->ref.load() == 0)
delete fontEngine;
}
}
for (it = accessPointConfigurations.constBegin(),
end = accessPointConfigurations.constEnd(); it != end; ++it) {
- if (it.value()->ref > 1)
+ if (it.value()->ref.load() > 1)
return true;
}
for (it = snapConfigurations.constBegin(),
end = snapConfigurations.constEnd(); it != end; ++it) {
- if (it.value()->ref > 1)
+ if (it.value()->ref.load() > 1)
return true;
}
for (it = userChoiceConfigurations.constBegin(),
end = userChoiceConfigurations.constEnd(); it != end; ++it) {
- if (it.value()->ref > 1)
+ if (it.value()->ref.load() > 1)
return true;
}
template<> void QSharedDataPointer<QNetworkProxyPrivate>::detach()
{
- if (d && d->ref == 1)
+ if (d && d->ref.load() == 1)
return;
QNetworkProxyPrivate *x = (d ? new QNetworkProxyPrivate(*d)
: new QNetworkProxyPrivate);
template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach()
{
- if (d && d->ref == 1)
+ if (d && d->ref.load() == 1)
return;
QNetworkProxyQueryPrivate *x = (d ? new QNetworkProxyQueryPrivate(*d)
: new QNetworkProxyQueryPrivate);
*/
void QGLFormat::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QGLFormatPrivate *newd = new QGLFormatPrivate(d);
if (!d->ref.deref())
delete d;
return;
// Make sure 'context' is not already shared with another group of contexts.
- Q_ASSERT(context->d_ptr->group->m_refs == 1);
+ Q_ASSERT(context->d_ptr->group->m_refs.load() == 1);
// Free 'context' group resources and make it use the same resources as 'share'.
QGLContextGroup *group = share->d_ptr->group;
*/
void QGLFramebufferObjectFormat::detach()
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QGLFramebufferObjectFormatPrivate *newd
= new QGLFramebufferObjectFormatPrivate(d);
if (!d->ref.deref())
return;
}
- if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) {
- d->lastSerial = d->serialNumber;
+ int serial = d->serialNumber.load();
+ if (!d->threadData->canWait || (serial != d->lastSerial)) {
+ d->lastSerial = serial;
QWindowSystemInterface::sendWindowSystemEvents(d->q_func(), QEventLoop::AllEvents);
}
}
void QSqlDatabasePrivate::invalidateDb(const QSqlDatabase &db, const QString &name, bool doWarn)
{
- if (db.d->ref != 1 && doWarn) {
+ if (db.d->ref.load() != 1 && doWarn) {
qWarning("QSqlDatabasePrivate::removeDatabase: connection '%s' is still in use, "
"all queries will cease to work.", name.toLocal8Bit().constData());
db.d->disable();
bool QSqlQuery::exec(const QString& query)
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
bool fo = isForwardOnly();
*this = QSqlQuery(driver()->createResult());
d->sqlResult->setNumericalPrecisionPolicy(d->sqlResult->numericalPrecisionPolicy());
*/
bool QSqlQuery::prepare(const QString& query)
{
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
bool fo = isForwardOnly();
*this = QSqlQuery(driver()->createResult());
setForwardOnly(fo);
*/
bool QIcon::isDetached() const
{
- return !d || d->ref == 1;
+ return !d || d->ref.load() == 1;
}
/*! \internal
void QIcon::detach()
{
if (d) {
- if (d->ref != 1) {
+ if (d->ref.load() != 1) {
QIconPrivate *x = new QIconPrivate;
if (d->engine_version > 1) {
QIconEngineV2 *engine = static_cast<QIconEngineV2 *>(d->engine);
void QDomElementPrivate::removeAttribute(const QString& aname)
{
QDomNodePrivate* p = m_attr->removeNamedItem(aname);
- if (p && p->ref == 0)
+ if (p && p->ref.load() == 0)
delete p;
}