diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-05-30 11:33:32 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-01 09:34:50 +0200 |
commit | 6cb34bd5000b68d04b2798f6aa16134464573420 (patch) | |
tree | 9a5dc8a6a638cccf783c39ed593262c91bb2215c /src | |
parent | 2c65dce8f68bfb03848dbd395fd1501fd7cd1510 (diff) |
Avoid string-based lookup of signals
Change-Id: I5b83b5d07b6a5d2de86d0f37471cf59baa7b0e43
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlfile.cpp | 10 | ||||
-rw-r--r-- | src/quick/items/qquickrectangle.cpp | 3 | ||||
-rw-r--r-- | src/quick/items/qquickrectangle_p_p.h | 3 | ||||
-rw-r--r-- | src/quick/items/qquicktextcontrol.cpp | 5 | ||||
-rw-r--r-- | src/quick/util/qquickpixmapcache.cpp | 13 |
5 files changed, 18 insertions, 16 deletions
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp index 9bdd2cdabb..b0da80f102 100644 --- a/src/qml/qml/qqmlfile.cpp +++ b/src/qml/qml/qqmlfile.cpp @@ -43,6 +43,7 @@ #include <QtCore/qurl.h> #include <QtCore/qobject.h> +#include <QtCore/qmetaobject.h> #include <private/qqmlengine_p.h> #include <private/qqmlglobal_p.h> @@ -127,15 +128,14 @@ QQmlFileNetworkReply::QQmlFileNetworkReply(QQmlEngine *e, QQmlFilePrivate *p, co : m_engine(e), m_p(p), m_redirectCount(0), m_reply(0) { if (finishedIndex == -1) { + finishedIndex = QMetaMethod::fromSignal(&QQmlFileNetworkReply::finished).methodIndex(); + downloadProgressIndex = QMetaMethod::fromSignal(&QQmlFileNetworkReply::downloadProgress).methodIndex(); const QMetaObject *smo = &staticMetaObject; - finishedIndex = smo->indexOfSignal("finished()"); - downloadProgressIndex = smo->indexOfSignal("downloadProgress(qint64,qint64)"); networkFinishedIndex = smo->indexOfMethod("networkFinished()"); networkDownloadProgressIndex = smo->indexOfMethod("networkDownloadProgress(qint64,qint64)"); - const QMetaObject *rsmo = &QNetworkReply::staticMetaObject; - replyFinishedIndex = rsmo->indexOfSignal("finished()"); - replyDownloadProgressIndex = rsmo->indexOfSignal("downloadProgress(qint64,qint64)"); + replyFinishedIndex = QMetaMethod::fromSignal(&QNetworkReply::finished).methodIndex(); + replyDownloadProgressIndex = QMetaMethod::fromSignal(&QNetworkReply::downloadProgress).methodIndex(); } Q_ASSERT(finishedIndex != -1 && downloadProgressIndex != -1 && networkFinishedIndex != -1 && networkDownloadProgressIndex != -1 && diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp index f4fe4714ea..b4156d9749 100644 --- a/src/quick/items/qquickrectangle.cpp +++ b/src/quick/items/qquickrectangle.cpp @@ -48,6 +48,7 @@ #include <QtGui/qpixmapcache.h> #include <QtCore/qstringbuilder.h> #include <QtCore/qmath.h> +#include <QtCore/qmetaobject.h> QT_BEGIN_NAMESPACE @@ -414,7 +415,7 @@ void QQuickRectangle::setGradient(QQuickGradient *gradient) return; static int updatedSignalIdx = -1; if (updatedSignalIdx < 0) - updatedSignalIdx = QQuickGradient::staticMetaObject.indexOfSignal("updated()"); + updatedSignalIdx = QMetaMethod::fromSignal(&QQuickGradient::updated).methodIndex(); if (d->doUpdateSlotIdx < 0) d->doUpdateSlotIdx = QQuickRectangle::staticMetaObject.indexOfSlot("doUpdate()"); if (d->gradient) diff --git a/src/quick/items/qquickrectangle_p_p.h b/src/quick/items/qquickrectangle_p_p.h index cb923ee563..934544b697 100644 --- a/src/quick/items/qquickrectangle_p_p.h +++ b/src/quick/items/qquickrectangle_p_p.h @@ -54,6 +54,7 @@ // #include "qquickitem_p.h" +#include <QtCore/qmetaobject.h> QT_BEGIN_NAMESPACE @@ -88,7 +89,7 @@ public: pen = new QQuickPen; static int penChangedSignalIdx = -1; if (penChangedSignalIdx < 0) - penChangedSignalIdx = QQuickPen::staticMetaObject.indexOfSignal("penChanged()"); + penChangedSignalIdx = QMetaMethod::fromSignal(&QQuickPen::penChanged).methodIndex(); if (doUpdateSlotIdx < 0) doUpdateSlotIdx = QQuickRectangle::staticMetaObject.indexOfSlot("doUpdate()"); QMetaObject::connect(pen, penChangedSignalIdx, q, doUpdateSlotIdx); diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 751706dce1..b390679a4b 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -69,6 +69,7 @@ #include <qvariant.h> #include <qurl.h> #include <qstylehints.h> +#include <qmetaobject.h> // ### these should come from QStyleHints const int textCursorWidth = 1; @@ -321,8 +322,8 @@ void QQuickTextControlPrivate::setContent(Qt::TextFormat format, const QString & doc->setUndoRedoEnabled(false); //Saving the index save some time. - static int contentsChangedIndex = QTextDocument::staticMetaObject.indexOfSignal("contentsChanged()"); - static int textChangedIndex = QQuickTextControl::staticMetaObject.indexOfSignal("textChanged()"); + static int contentsChangedIndex = QMetaMethod::fromSignal(&QTextDocument::contentsChanged).methodIndex(); + static int textChangedIndex = QMetaMethod::fromSignal(&QQuickTextControl::textChanged).methodIndex(); // avoid multiple textChanged() signals being emitted QMetaObject::disconnect(doc, contentsChangedIndex, q, textChangedIndex); diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 9f11062674..3b9c59e5e3 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -66,6 +66,7 @@ #include <private/qobject_p.h> #include <QSslError> #include <QQmlFile> +#include <QMetaMethod> #define IMAGEREQUEST_MAX_REQUEST_COUNT 8 #define IMAGEREQUEST_MAX_REDIRECT_RECURSION 16 @@ -633,12 +634,10 @@ void QQuickPixmapReader::cancel(QQuickPixmapReply *reply) void QQuickPixmapReader::run() { if (replyDownloadProgress == -1) { - const QMetaObject *nr = &QNetworkReply::staticMetaObject; - const QMetaObject *pr = &QQuickPixmapReply::staticMetaObject; + replyDownloadProgress = QMetaMethod::fromSignal(&QNetworkReply::downloadProgress).methodIndex(); + replyFinished = QMetaMethod::fromSignal(&QNetworkReply::finished).methodIndex(); + downloadProgress = QMetaMethod::fromSignal(&QQuickPixmapReply::downloadProgress).methodIndex(); const QMetaObject *ir = &QQuickPixmapReaderThreadObject::staticMetaObject; - replyDownloadProgress = nr->indexOfSignal("downloadProgress(qint64,qint64)"); - replyFinished = nr->indexOfSignal("finished()"); - downloadProgress = pr->indexOfSignal("downloadProgress(qint64,qint64)"); threadNetworkRequestDone = ir->indexOfSlot("networkRequestDone()"); } @@ -832,8 +831,8 @@ QQuickPixmapReply::QQuickPixmapReply(QQuickPixmapData *d) : data(d), engineForReader(0), requestSize(d->requestSize), url(d->url), loading(false), redirectCount(0) { if (finishedIndex == -1) { - finishedIndex = QQuickPixmapReply::staticMetaObject.indexOfSignal("finished()"); - downloadProgressIndex = QQuickPixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)"); + finishedIndex = QMetaMethod::fromSignal(&QQuickPixmapReply::finished).methodIndex(); + downloadProgressIndex = QMetaMethod::fromSignal(&QQuickPixmapReply::downloadProgress).methodIndex(); } } |