Fix most warnings about assignments of QAtomicInt.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Mon, 31 Oct 2011 09:36:57 +0000 (10:36 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 31 Oct 2011 10:29:08 +0000 (11:29 +0100)
Change-Id: Ide409d72d2637b68ec2a85aaca4bc783a7e911e7
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
20 files changed:
src/corelib/concurrent/qfuturewatcher.cpp
src/corelib/io/qurl.cpp
src/corelib/kernel/qeventdispatcher_glib.cpp
src/corelib/kernel/qobject.cpp
src/dbus/qdbusargument.cpp
src/dbus/qdbusintegrator.cpp
src/dbus/qdbusunixfiledescriptor.cpp
src/gui/kernel/qcursor_qpa.cpp
src/gui/kernel/qevent_p.h
src/gui/kernel/qkeysequence_p.h
src/gui/painting/qpainterpath.h
src/gui/painting/qpainterpath_p.h
src/gui/painting/qpen.cpp
src/gui/text/qfontengine_ft.cpp
src/gui/text/qstatictext_p.h
src/network/kernel/qauthenticator.cpp
src/network/ssl/qsslsocket.cpp
src/sql/kernel/qsqldatabase.cpp
src/sql/kernel/qsqlrecord.cpp
src/xml/dom/qdom.cpp

index c9a16a8..e405896 100644 (file)
@@ -400,7 +400,7 @@ void QFutureWatcherBase::disconnectOutputInterface(bool pendingAssignment)
 {
     if (pendingAssignment) {
         Q_D(QFutureWatcherBase);
-        d->pendingResultsReady = 0;
+        d->pendingResultsReady.store(0);
         qDeleteAll(d->pendingCallOutEvents);
         d->pendingCallOutEvents.clear();
         d->finished = false;
@@ -439,7 +439,7 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event)
             emit q->finished();
         break;
         case QFutureCallOutEvent::Canceled:
-            pendingResultsReady = 0;
+            pendingResultsReady.store(0);
             emit q->canceled();
         break;
         case QFutureCallOutEvent::Paused:
index b960528..c921a89 100644 (file)
@@ -3407,23 +3407,15 @@ static QString qt_ACE_do(const QString &domain, AceOperation op)
     return result;
 }
 
-
-QUrlPrivate::QUrlPrivate()
+QUrlPrivate::QUrlPrivate() : ref(1), port(-1), parsingMode(QUrl::TolerantMode),
+    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)
-    : scheme(copy.scheme),
+    : ref(1), scheme(copy.scheme),
       userName(copy.userName),
       password(copy.password),
       host(copy.host),
@@ -3445,7 +3437,8 @@ QUrlPrivate::QUrlPrivate(const QUrlPrivate &copy)
       pairDelimiter(copy.pairDelimiter),
       stateFlags(copy.stateFlags),
       encodedNormalized(copy.encodedNormalized)
-{ ref = 1; }
+{
+}
 
 QString QUrlPrivate::canonicalHost() const
 {
index 176048d..0773915 100644 (file)
@@ -264,7 +264,7 @@ static gboolean postEventSourcePrepare(GSource *s, gint *timeout)
 
     GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
     return (!data->canWait
-            || (source->serialNumber != source->lastSerialNumber));
+            || (source->serialNumber.load() != source->lastSerialNumber));
 }
 
 static gboolean postEventSourceCheck(GSource *source)
@@ -275,7 +275,7 @@ static gboolean postEventSourceCheck(GSource *source)
 static gboolean postEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
 {
     GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
-    source->lastSerialNumber = source->serialNumber;
+    source->lastSerialNumber = source->serialNumber.load();
     QCoreApplication::sendPostedEvents();
     source->d->runTimersOnceWithNormalPriority();
     return true; // i dunno, george...
@@ -320,7 +320,7 @@ QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context)
     // setup post event source
     postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs,
                                                                         sizeof(GPostEventSource)));
-    postEventSource->serialNumber = 1;
+    postEventSource->serialNumber.store(1);
     postEventSource->d = this;
     g_source_set_can_recurse(&postEventSource->source, true);
     g_source_attach(&postEventSource->source, mainContext);
index 555bfa6..6bca22b 100644 (file)
@@ -3011,7 +3011,7 @@ bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index,
     c->method_relative = method_index;
     c->method_offset = method_offset;
     c->connectionType = type;
-    c->argumentTypes = types;
+    c->argumentTypes.store(types);
     c->nextConnectionList = 0;
     c->callFunction = callFunction;
 
index 251859d..af800d7 100644 (file)
@@ -113,7 +113,7 @@ bool QDBusArgumentPrivate::checkWrite(QDBusArgumentPrivate *&d)
         if (!d->marshaller()->ok)
             return false;
 
-        if (d->message && d->ref != 1) {
+        if (d->message && d->ref.load() != 1) {
             QDBusMarshaller *dd = new QDBusMarshaller(d->capabilities);
             dd->message = q_dbus_message_copy(d->message);
             q_dbus_message_iter_init_append(dd->message, &dd->iterator);
@@ -154,7 +154,7 @@ bool QDBusArgumentPrivate::checkReadAndDetach(QDBusArgumentPrivate *&d)
     if (!checkRead(d))
         return false;           //  don't bother
 
-    if (d->ref == 1)
+    if (d->ref.load() == 1)
         return true;            // no need to detach
 
     QDBusDemarshaller *dd = new QDBusDemarshaller(d->capabilities);
index 8bb7487..f6b433e 100644 (file)
@@ -557,7 +557,7 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
         (*(*list)[i])(amsg);
     }
 
-    if (!ref)
+    if (!ref.load())
         return false;
 
     switch (amsg.type()) {
@@ -1981,7 +1981,7 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM
 
     checkThread();
     QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this);
-    pcall->ref = 0;
+    pcall->ref.store(0);
 
     QDBusError error;
     DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, capabilities, &error);
index 86d2b3c..0ee29fc 100644 (file)
@@ -194,7 +194,7 @@ QDBusUnixFileDescriptor::~QDBusUnixFileDescriptor()
 */
 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
 {
-    return d ? d->fd.operator int() : -1;
+    return d ? d->fd.load() : -1;
 }
 
 // actual implementation
@@ -269,11 +269,12 @@ void QDBusUnixFileDescriptor::giveFileDescriptor(int fileDescriptor)
     else
         d = new QDBusUnixFileDescriptorPrivate;
 
-    if (d->fd != -1)
-        qt_safe_close(d->fd);
+    const int fdl = d->fd.load();
+    if (fdl != -1)
+        qt_safe_close(fdl);
 
     if (fileDescriptor != -1)
-        d->fd = fileDescriptor;
+        d->fd.store(fileDescriptor);
 }
 
 /*!
@@ -294,8 +295,9 @@ int QDBusUnixFileDescriptor::takeFileDescriptor()
 
 QDBusUnixFileDescriptorPrivate::~QDBusUnixFileDescriptorPrivate()
 {
-    if (fd != -1)
-        qt_safe_close(fd);
+    const int fdl = fd.load();
+    if (fdl != -1)
+        qt_safe_close(fdl);
 }
 
 #else
index 40a1531..7b3059e 100644 (file)
@@ -58,9 +58,8 @@ static int nextCursorId = Qt::BitmapCursor;
  *****************************************************************************/
 
 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()
index 1d65eb6..fa6b675 100644 (file)
@@ -91,7 +91,7 @@ public:
     inline QTouchEventTouchPointPrivate *detach()
     {
         QTouchEventTouchPointPrivate *d = new QTouchEventTouchPointPrivate(*this);
-        d->ref = 1;
+        d->ref.store(1);
         if (!this->ref.deref())
             delete this;
         return d;
index eb8527a..7fa98dd 100644 (file)
@@ -69,14 +69,12 @@ struct Q_AUTOTEST_EXPORT QKeyBinding
 class Q_AUTOTEST_EXPORT QKeySequencePrivate
 {
 public:
-    inline QKeySequencePrivate()
+    inline QKeySequencePrivate() : ref(1)
     {
-        ref = 1;
         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[1] = copy.key[1];
         key[2] = copy.key[2];
index 9dc435f..a558abc 100644 (file)
@@ -249,6 +249,9 @@ public:
     friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPainterPath &);
     friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
 #endif
+
+    QPainterPathPrivate() : ref(1) {}
+
 private:
     QAtomicInt ref;
     QVector<QPainterPath::Element> elements;
index 93cc11c..8d5bd73 100644 (file)
@@ -148,13 +148,12 @@ public:
         dirtyControlBounds(false),
         pathConverter(0)
     {
-        ref = 1;
         require_moveTo = false;
         convex = false;
     }
 
     QPainterPathData(const QPainterPathData &other) :
-        QPainterPathPrivate(), cStart(other.cStart), fillRule(other.fillRule),
+        cStart(other.cStart), fillRule(other.fillRule),
         bounds(other.bounds),
         controlBounds(other.controlBounds),
         dirtyBounds(other.dirtyBounds),
@@ -162,7 +161,6 @@ public:
         convex(other.convex),
         pathConverter(0)
     {
-        ref = 1;
         require_moveTo = false;
         elements = other.elements;
     }
index 5a4582e..5358239 100644 (file)
@@ -358,7 +358,7 @@ void QPen::detach()
     QPenData *x = new QPenData(*static_cast<QPenData *>(d));
     if (!d->ref.deref())
         delete d;
-    x->ref = 1;
+    x->ref.store(1);
     d = x;
 }
 
index 37bbd4f..7c95af3 100644 (file)
@@ -259,7 +259,7 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id,
 
         newFreetype->hbFace = qHBNewFace(face, hb_getSFntTable);
         Q_CHECK_PTR(newFreetype->hbFace);
-        newFreetype->ref = 1;
+        newFreetype->ref.store(1);
         newFreetype->xsize = 0;
         newFreetype->ysize = 0;
         newFreetype->matrix.xx = 0x10000;
index c84e853..5f9410c 100644 (file)
@@ -68,7 +68,7 @@ public:
         OpenGLUserData
     };
 
-    QStaticTextUserData(Type t) : type(t) { ref = 0; }
+    QStaticTextUserData(Type t) : ref(0), type(t) {}
     virtual ~QStaticTextUserData() {}
 
     QAtomicInt ref;
index 0423e22..8e64968 100644 (file)
@@ -264,7 +264,7 @@ void QAuthenticator::detach()
 {
     if (!d) {
         d = new QAuthenticatorPrivate;
-        d->ref = 1;
+        d->ref.store(1);
         return;
     }
 
index 2fb0407..7aac889 100644 (file)
@@ -870,7 +870,7 @@ QSslConfiguration QSslSocket::sslConfiguration() const
 
     // create a deep copy of our 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();
 
     return QSslConfiguration(copy);
@@ -2039,7 +2039,7 @@ void QSslConfigurationPrivate::deepCopyDefaultConfiguration(QSslConfigurationPri
         return;
     }
 
-    ptr->ref = 1;
+    ptr->ref.store(1);
     ptr->peerCertificate = global->peerCertificate;
     ptr->peerCertificateChain = global->peerCertificateChain;
     ptr->localCertificate = global->localCertificate;
index a53120c..6aa45c4 100644 (file)
@@ -133,11 +133,11 @@ class QSqlDatabasePrivate
 {
 public:
     QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0):
+        ref(1),
         q(d),
         driver(dr),
         port(-1)
     {
-        ref = 1;
         if(driver)
             precisionPolicy = driver->numericalPrecisionPolicy();
         else
@@ -171,9 +171,8 @@ public:
     static void cleanConnections();
 };
 
-QSqlDatabasePrivate::QSqlDatabasePrivate(const QSqlDatabasePrivate &other)
+QSqlDatabasePrivate::QSqlDatabasePrivate(const QSqlDatabasePrivate &other) : ref(1)
 {
-    ref = 1;
     q = other.q;
     dbname = other.dbname;
     uname = other.uname;
index 944f2fc..3f14cba 100644 (file)
@@ -63,14 +63,12 @@ public:
     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
index 29798d8..5aa7311 100644 (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;
     if (node_impl)
         node_impl->ref.ref();
     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;
     if (node_impl)
         node_impl->ref.ref();
@@ -1172,9 +1171,9 @@ QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString
     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;
     if (node_impl)
         node_impl->ref.ref();
@@ -1449,9 +1448,8 @@ inline void QDomNodePrivate::setOwnerDocument(QDomDocumentPrivate *doc)
     hasParent = false;
 }
 
-QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par)
+QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) : ref(1)
 {
-    ref = 1;
     if (par)
         setParent(par);
     else
@@ -1465,9 +1463,8 @@ QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par)
     columnNumber = -1;
 }
 
-QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n, bool deep)
+QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n, bool deep) : ref(1)
 {
-    ref = 1;
     setOwnerDocument(n->ownerDocument());
     prev = 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;
     parent = n;
     appendToParent = false;