Fix most warnings about assignments of QAtomicInt.

Change-Id: Ide409d72d2637b68ec2a85aaca4bc783a7e911e7
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
Friedemann Kleint 2011-10-31 10:36:57 +01:00 committed by Qt by Nokia
parent 5761d8546f
commit e277575987
20 changed files with 52 additions and 66 deletions

View File

@ -400,7 +400,7 @@ void QFutureWatcherBase::disconnectOutputInterface(bool pendingAssignment)
{ {
if (pendingAssignment) { if (pendingAssignment) {
Q_D(QFutureWatcherBase); Q_D(QFutureWatcherBase);
d->pendingResultsReady = 0; d->pendingResultsReady.store(0);
qDeleteAll(d->pendingCallOutEvents); qDeleteAll(d->pendingCallOutEvents);
d->pendingCallOutEvents.clear(); d->pendingCallOutEvents.clear();
d->finished = false; d->finished = false;
@ -439,7 +439,7 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
emit q->finished(); emit q->finished();
break; break;
case QFutureCallOutEvent::Canceled: case QFutureCallOutEvent::Canceled:
pendingResultsReady = 0; pendingResultsReady.store(0);
emit q->canceled(); emit q->canceled();
break; break;
case QFutureCallOutEvent::Paused: case QFutureCallOutEvent::Paused:

View File

@ -3407,23 +3407,15 @@ static QString qt_ACE_do(const QString &domain, AceOperation op)
return result; return result;
} }
QUrlPrivate::QUrlPrivate() : ref(1), port(-1), parsingMode(QUrl::TolerantMode),
QUrlPrivate::QUrlPrivate() hasQuery(false), hasFragment(false), isValid(false), isHostValid(true),
valueDelimiter('='), pairDelimiter('&'),
stateFlags(0)
{ {
ref = 1;
port = -1;
isValid = false;
isHostValid = true;
parsingMode = QUrl::TolerantMode;
valueDelimiter = '=';
pairDelimiter = '&';
stateFlags = 0;
hasFragment = false;
hasQuery = false;
} }
QUrlPrivate::QUrlPrivate(const QUrlPrivate &copy) QUrlPrivate::QUrlPrivate(const QUrlPrivate &copy)
: scheme(copy.scheme), : ref(1), scheme(copy.scheme),
userName(copy.userName), userName(copy.userName),
password(copy.password), password(copy.password),
host(copy.host), host(copy.host),
@ -3445,7 +3437,8 @@ QUrlPrivate::QUrlPrivate(const QUrlPrivate &copy)
pairDelimiter(copy.pairDelimiter), pairDelimiter(copy.pairDelimiter),
stateFlags(copy.stateFlags), stateFlags(copy.stateFlags),
encodedNormalized(copy.encodedNormalized) encodedNormalized(copy.encodedNormalized)
{ ref = 1; } {
}
QString QUrlPrivate::canonicalHost() const QString QUrlPrivate::canonicalHost() const
{ {

View File

@ -264,7 +264,7 @@ static gboolean postEventSourcePrepare(GSource *s, gint *timeout)
GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s); GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
return (!data->canWait return (!data->canWait
|| (source->serialNumber != source->lastSerialNumber)); || (source->serialNumber.load() != source->lastSerialNumber));
} }
static gboolean postEventSourceCheck(GSource *source) static gboolean postEventSourceCheck(GSource *source)
@ -275,7 +275,7 @@ static gboolean postEventSourceCheck(GSource *source)
static gboolean postEventSourceDispatch(GSource *s, GSourceFunc, gpointer) static gboolean postEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
{ {
GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s); GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
source->lastSerialNumber = source->serialNumber; source->lastSerialNumber = source->serialNumber.load();
QCoreApplication::sendPostedEvents(); QCoreApplication::sendPostedEvents();
source->d->runTimersOnceWithNormalPriority(); source->d->runTimersOnceWithNormalPriority();
return true; // i dunno, george... return true; // i dunno, george...
@ -320,7 +320,7 @@ QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context)
// setup post event source // setup post event source
postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs, postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs,
sizeof(GPostEventSource))); sizeof(GPostEventSource)));
postEventSource->serialNumber = 1; postEventSource->serialNumber.store(1);
postEventSource->d = this; postEventSource->d = this;
g_source_set_can_recurse(&postEventSource->source, true); g_source_set_can_recurse(&postEventSource->source, true);
g_source_attach(&postEventSource->source, mainContext); g_source_attach(&postEventSource->source, mainContext);

View File

@ -3011,7 +3011,7 @@ bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index,
c->method_relative = method_index; c->method_relative = method_index;
c->method_offset = method_offset; c->method_offset = method_offset;
c->connectionType = type; c->connectionType = type;
c->argumentTypes = types; c->argumentTypes.store(types);
c->nextConnectionList = 0; c->nextConnectionList = 0;
c->callFunction = callFunction; c->callFunction = callFunction;

View File

@ -113,7 +113,7 @@ bool QDBusArgumentPrivate::checkWrite(QDBusArgumentPrivate *&d)
if (!d->marshaller()->ok) if (!d->marshaller()->ok)
return false; return false;
if (d->message && d->ref != 1) { if (d->message && d->ref.load() != 1) {
QDBusMarshaller *dd = new QDBusMarshaller(d->capabilities); QDBusMarshaller *dd = new QDBusMarshaller(d->capabilities);
dd->message = q_dbus_message_copy(d->message); dd->message = q_dbus_message_copy(d->message);
q_dbus_message_iter_init_append(dd->message, &dd->iterator); q_dbus_message_iter_init_append(dd->message, &dd->iterator);
@ -154,7 +154,7 @@ bool QDBusArgumentPrivate::checkReadAndDetach(QDBusArgumentPrivate *&d)
if (!checkRead(d)) if (!checkRead(d))
return false; // don't bother return false; // don't bother
if (d->ref == 1) if (d->ref.load() == 1)
return true; // no need to detach return true; // no need to detach
QDBusDemarshaller *dd = new QDBusDemarshaller(d->capabilities); QDBusDemarshaller *dd = new QDBusDemarshaller(d->capabilities);

View File

@ -557,7 +557,7 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
(*(*list)[i])(amsg); (*(*list)[i])(amsg);
} }
if (!ref) if (!ref.load())
return false; return false;
switch (amsg.type()) { switch (amsg.type()) {
@ -1981,7 +1981,7 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM
checkThread(); checkThread();
QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this); QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this);
pcall->ref = 0; pcall->ref.store(0);
QDBusError error; QDBusError error;
DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error); DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error);

View File

@ -194,7 +194,7 @@ QDBusUnixFileDescriptor::~QDBusUnixFileDescriptor()
*/ */
bool QDBusUnixFileDescriptor::isValid() const bool QDBusUnixFileDescriptor::isValid() const
{ {
return d ? d->fd != -1 : false; return d ? d->fd.load() != -1 : false;
} }
/*! /*!
@ -212,7 +212,7 @@ bool QDBusUnixFileDescriptor::isValid() const
*/ */
int QDBusUnixFileDescriptor::fileDescriptor() const int QDBusUnixFileDescriptor::fileDescriptor() const
{ {
return d ? d->fd.operator int() : -1; return d ? d->fd.load() : -1;
} }
// actual implementation // actual implementation
@ -269,11 +269,12 @@ void QDBusUnixFileDescriptor::giveFileDescriptor(int fileDescriptor)
else else
d = new QDBusUnixFileDescriptorPrivate; d = new QDBusUnixFileDescriptorPrivate;
if (d->fd != -1) const int fdl = d->fd.load();
qt_safe_close(d->fd); if (fdl != -1)
qt_safe_close(fdl);
if (fileDescriptor != -1) if (fileDescriptor != -1)
d->fd = fileDescriptor; d->fd.store(fileDescriptor);
} }
/*! /*!
@ -294,8 +295,9 @@ int QDBusUnixFileDescriptor::takeFileDescriptor()
QDBusUnixFileDescriptorPrivate::~QDBusUnixFileDescriptorPrivate() QDBusUnixFileDescriptorPrivate::~QDBusUnixFileDescriptorPrivate()
{ {
if (fd != -1) const int fdl = fd.load();
qt_safe_close(fd); if (fdl != -1)
qt_safe_close(fdl);
} }
#else #else

View File

@ -58,9 +58,8 @@ static int nextCursorId = Qt::BitmapCursor;
*****************************************************************************/ *****************************************************************************/
QCursorData::QCursorData(Qt::CursorShape s) QCursorData::QCursorData(Qt::CursorShape s)
: cshape(s), bm(0), bmm(0), hx(0), hy(0), id(s) : ref(1), cshape(s), bm(0), bmm(0), hx(0), hy(0), id(s)
{ {
ref = 1;
} }
QCursorData::~QCursorData() QCursorData::~QCursorData()

View File

@ -91,7 +91,7 @@ public:
inline QTouchEventTouchPointPrivate *detach() inline QTouchEventTouchPointPrivate *detach()
{ {
QTouchEventTouchPointPrivate *d = new QTouchEventTouchPointPrivate(*this); QTouchEventTouchPointPrivate *d = new QTouchEventTouchPointPrivate(*this);
d->ref = 1; d->ref.store(1);
if (!this->ref.deref()) if (!this->ref.deref())
delete this; delete this;
return d; return d;

View File

@ -69,14 +69,12 @@ struct Q_AUTOTEST_EXPORT QKeyBinding
class Q_AUTOTEST_EXPORT QKeySequencePrivate class Q_AUTOTEST_EXPORT QKeySequencePrivate
{ {
public: public:
inline QKeySequencePrivate() inline QKeySequencePrivate() : ref(1)
{ {
ref = 1;
key[0] = key[1] = key[2] = key[3] = 0; key[0] = key[1] = key[2] = key[3] = 0;
} }
inline QKeySequencePrivate(const QKeySequencePrivate &copy) inline QKeySequencePrivate(const QKeySequencePrivate &copy) : ref(1)
{ {
ref = 1;
key[0] = copy.key[0]; key[0] = copy.key[0];
key[1] = copy.key[1]; key[1] = copy.key[1];
key[2] = copy.key[2]; key[2] = copy.key[2];

View File

@ -249,6 +249,9 @@ public:
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &); friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &);
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &); friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
#endif #endif
QPainterPathPrivate() : ref(1) {}
private: private:
QAtomicInt ref; QAtomicInt ref;
QVector<QPainterPath::Element> elements; QVector<QPainterPath::Element> elements;

View File

@ -148,13 +148,12 @@ public:
dirtyControlBounds(false), dirtyControlBounds(false),
pathConverter(0) pathConverter(0)
{ {
ref = 1;
require_moveTo = false; require_moveTo = false;
convex = false; convex = false;
} }
QPainterPathData(const QPainterPathData &other) : QPainterPathData(const QPainterPathData &other) :
QPainterPathPrivate(), cStart(other.cStart), fillRule(other.fillRule), cStart(other.cStart), fillRule(other.fillRule),
bounds(other.bounds), bounds(other.bounds),
controlBounds(other.controlBounds), controlBounds(other.controlBounds),
dirtyBounds(other.dirtyBounds), dirtyBounds(other.dirtyBounds),
@ -162,7 +161,6 @@ public:
convex(other.convex), convex(other.convex),
pathConverter(0) pathConverter(0)
{ {
ref = 1;
require_moveTo = false; require_moveTo = false;
elements = other.elements; elements = other.elements;
} }

View File

@ -358,7 +358,7 @@ void QPen::detach()
QPenData *x = new QPenData(*static_cast<QPenData *>(d)); QPenData *x = new QPenData(*static_cast<QPenData *>(d));
if (!d->ref.deref()) if (!d->ref.deref())
delete d; delete d;
x->ref = 1; x->ref.store(1);
d = x; d = x;
} }

View File

@ -259,7 +259,7 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id,
newFreetype->hbFace = qHBNewFace(face, hb_getSFntTable); newFreetype->hbFace = qHBNewFace(face, hb_getSFntTable);
Q_CHECK_PTR(newFreetype->hbFace); Q_CHECK_PTR(newFreetype->hbFace);
newFreetype->ref = 1; newFreetype->ref.store(1);
newFreetype->xsize = 0; newFreetype->xsize = 0;
newFreetype->ysize = 0; newFreetype->ysize = 0;
newFreetype->matrix.xx = 0x10000; newFreetype->matrix.xx = 0x10000;

View File

@ -68,7 +68,7 @@ public:
OpenGLUserData OpenGLUserData
}; };
QStaticTextUserData(Type t) : type(t) { ref = 0; } QStaticTextUserData(Type t) : ref(0), type(t) {}
virtual ~QStaticTextUserData() {} virtual ~QStaticTextUserData() {}
QAtomicInt ref; QAtomicInt ref;

View File

@ -264,7 +264,7 @@ void QAuthenticator::detach()
{ {
if (!d) { if (!d) {
d = new QAuthenticatorPrivate; d = new QAuthenticatorPrivate;
d->ref = 1; d->ref.store(1);
return; return;
} }

View File

@ -870,7 +870,7 @@ QSslConfiguration QSslSocket::sslConfiguration() const
// create a deep copy of our configuration // create a deep copy of our configuration
QSslConfigurationPrivate *copy = new QSslConfigurationPrivate(d->configuration); QSslConfigurationPrivate *copy = new QSslConfigurationPrivate(d->configuration);
copy->ref = 0; // the QSslConfiguration constructor refs up copy->ref.store(0); // the QSslConfiguration constructor refs up
copy->sessionCipher = d->sessionCipher(); copy->sessionCipher = d->sessionCipher();
return QSslConfiguration(copy); return QSslConfiguration(copy);
@ -2039,7 +2039,7 @@ void QSslConfigurationPrivate::deepCopyDefaultConfiguration(QSslConfigurationPri
return; return;
} }
ptr->ref = 1; ptr->ref.store(1);
ptr->peerCertificate = global->peerCertificate; ptr->peerCertificate = global->peerCertificate;
ptr->peerCertificateChain = global->peerCertificateChain; ptr->peerCertificateChain = global->peerCertificateChain;
ptr->localCertificate = global->localCertificate; ptr->localCertificate = global->localCertificate;

View File

@ -133,11 +133,11 @@ class QSqlDatabasePrivate
{ {
public: public:
QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0): QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0):
ref(1),
q(d), q(d),
driver(dr), driver(dr),
port(-1) port(-1)
{ {
ref = 1;
if(driver) if(driver)
precisionPolicy = driver->numericalPrecisionPolicy(); precisionPolicy = driver->numericalPrecisionPolicy();
else else
@ -171,9 +171,8 @@ public:
static void cleanConnections(); static void cleanConnections();
}; };
QSqlDatabasePrivate::QSqlDatabasePrivate(const QSqlDatabasePrivate &other) QSqlDatabasePrivate::QSqlDatabasePrivate(const QSqlDatabasePrivate &other) : ref(1)
{ {
ref = 1;
q = other.q; q = other.q;
dbname = other.dbname; dbname = other.dbname;
uname = other.uname; uname = other.uname;

View File

@ -63,14 +63,12 @@ public:
QAtomicInt ref; QAtomicInt ref;
}; };
QSqlRecordPrivate::QSqlRecordPrivate() QSqlRecordPrivate::QSqlRecordPrivate() : ref(1)
{ {
ref = 1;
} }
QSqlRecordPrivate::QSqlRecordPrivate(const QSqlRecordPrivate &other): fields(other.fields) QSqlRecordPrivate::QSqlRecordPrivate(const QSqlRecordPrivate &other): fields(other.fields), ref(1)
{ {
ref = 1;
} }
/*! \internal /*! \internal

View File

@ -1153,18 +1153,17 @@ void QDomImplementation::setInvalidDataPolicy(InvalidDataPolicy policy)
* *
**************************************************************/ **************************************************************/
QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl) QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl) : ref(1)
{ {
ref = 1;
node_impl = n_impl; node_impl = n_impl;
if (node_impl) if (node_impl)
node_impl->ref.ref(); node_impl->ref.ref();
timestamp = 0; timestamp = 0;
} }
QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &name) QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &name) :
ref(1)
{ {
ref = 1;
node_impl = n_impl; node_impl = n_impl;
if (node_impl) if (node_impl)
node_impl->ref.ref(); node_impl->ref.ref();
@ -1172,9 +1171,9 @@ QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString
timestamp = 0; timestamp = 0;
} }
QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &_nsURI, const QString &localName) QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &_nsURI, const QString &localName) :
ref(1)
{ {
ref = 1;
node_impl = n_impl; node_impl = n_impl;
if (node_impl) if (node_impl)
node_impl->ref.ref(); node_impl->ref.ref();
@ -1449,9 +1448,8 @@ inline void QDomNodePrivate::setOwnerDocument(QDomDocumentPrivate *doc)
hasParent = false; hasParent = false;
} }
QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) : ref(1)
{ {
ref = 1;
if (par) if (par)
setParent(par); setParent(par);
else else
@ -1465,9 +1463,8 @@ QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par)
columnNumber = -1; columnNumber = -1;
} }
QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n, bool deep) QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n, bool deep) : ref(1)
{ {
ref = 1;
setOwnerDocument(n->ownerDocument()); setOwnerDocument(n->ownerDocument());
prev = 0; prev = 0;
next = 0; next = 0;
@ -3052,9 +3049,8 @@ int QDomNode::columnNumber() const
* *
**************************************************************/ **************************************************************/
QDomNamedNodeMapPrivate::QDomNamedNodeMapPrivate(QDomNodePrivate* n) QDomNamedNodeMapPrivate::QDomNamedNodeMapPrivate(QDomNodePrivate* n) : ref(1)
{ {
ref = 1;
readonly = false; readonly = false;
parent = n; parent = n;
appendToParent = false; appendToParent = false;