Port QtConcurrent to QMetaMethod-based connectNotify()
authorKent Hansen <kent.hansen@nokia.com>
Sun, 22 Apr 2012 12:23:53 +0000 (14:23 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 30 Apr 2012 23:18:03 +0000 (01:18 +0200)
The const char *-based API is deprecated and will be removed in Qt5.

Change-Id: Ica5b2c5020adf972db5005be8c062ddcdae8c0b4
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/concurrent/qfuturewatcher.cpp
src/concurrent/qfuturewatcher.h

index d3a1122..9153fe5 100644 (file)
@@ -45,6 +45,7 @@
 
 #include <QtCore/qcoreevent.h>
 #include <QtCore/qcoreapplication.h>
+#include <QtCore/qmetaobject.h>
 #include <QtCore/qthread.h>
 
 #include "qfuturewatcher_p.h"
@@ -354,13 +355,15 @@ void QFutureWatcherBase::setPendingResultsLimit(int limit)
     d->maximumPendingResultsReady = limit;
 }
 
-void QFutureWatcherBase::connectNotify(const char * signal)
+void QFutureWatcherBase::connectNotify(const QMetaMethod &signal)
 {
     Q_D(QFutureWatcherBase);
-    if (qstrcmp(signal, SIGNAL(resultReadyAt(int))) == 0)
+    static const QMetaMethod resultReadyAtSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::resultReadyAt);
+    if (signal == resultReadyAtSignal)
         d->resultAtConnected.ref();
 #ifndef QT_NO_DEBUG
-    if (qstrcmp(signal, SIGNAL(finished())) == 0) {
+    static const QMetaMethod finishedSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::finished);
+    if (signal == finishedSignal) {
         if (futureInterface().isRunning()) {
             //connections should be established before calling stFuture to avoid race.
             // (The future could finish before the connection is made.)
@@ -370,10 +373,11 @@ void QFutureWatcherBase::connectNotify(const char * signal)
 #endif
 }
 
-void QFutureWatcherBase::disconnectNotify(const char * signal)
+void QFutureWatcherBase::disconnectNotify(const QMetaMethod &signal)
 {
     Q_D(QFutureWatcherBase);
-    if (qstrcmp(signal, SIGNAL(resultReadyAt(int))) == 0)
+    static const QMetaMethod resultReadyAtSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::resultReadyAt);
+    if (signal == resultReadyAtSignal)
         d->resultAtConnected.deref();
 }
 
index 439a25d..c05f58e 100644 (file)
@@ -102,8 +102,8 @@ public Q_SLOTS:
     void togglePaused();
 
 protected:
-    void connectNotify (const char * signal);
-    void disconnectNotify (const char * signal);
+    void connectNotify (const QMetaMethod &signal);
+    void disconnectNotify (const QMetaMethod &signal);
 
     // called from setFuture() implemented in template sub-classes
     void connectOutputInterface();