aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2012-04-02 10:02:28 +1000
committerQt by Nokia <qt-info@nokia.com>2012-04-23 05:23:45 +0200
commit66399c6584a86180c1955e5d34617fa46b07f36e (patch)
treec6ed009879801ff7c2d13b696c7963ed08c809c6 /src/qml/qml
parent9542511b013588b2ceb132ec8b34879ec904a21e (diff)
Also check notifier endpoints when checking whether a signal is connected.
This is required for the QQmlBoundSignal optimizations. Change-Id: I63540b96cd7d4523ec49973a2540054c83d82b12 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmldata_p.h1
-rw-r--r--src/qml/qml/qqmlengine.cpp17
-rw-r--r--src/qml/qml/qqmlglobal_p.h15
3 files changed, 32 insertions, 1 deletions
diff --git a/src/qml/qml/qqmldata_p.h b/src/qml/qml/qqmldata_p.h
index b8eee47750..1a188f9e59 100644
--- a/src/qml/qml/qqmldata_p.h
+++ b/src/qml/qml/qqmldata_p.h
@@ -133,6 +133,7 @@ public:
inline QQmlNotifierEndpoint *notify(int index);
void addNotify(int index, QQmlNotifierEndpoint *);
int endpointCount(int index);
+ bool signalHasEndpoint(int index);
// The context that created the C++ object
QQmlContextData *context;
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 7317689907..c1ce012d27 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -77,13 +77,13 @@
#include <QtCore/qmetaobject.h>
#include <QNetworkAccessManager>
#include <QDebug>
-#include <QMetaObject>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdir.h>
#include <QtCore/qmutex.h>
#include <QtNetwork/qnetworkconfigmanager.h>
#include <private/qobject_p.h>
+#include <private/qmetaobject_p.h>
#include <private/qqmllocale_p.h>
@@ -1155,6 +1155,21 @@ void QQmlData::addNotify(int index, QQmlNotifierEndpoint *endpoint)
}
}
+bool QQml_isSignalConnected(QObject *obj, int signal_index, int index)
+{
+ QQmlData *data = QQmlData::get(obj);
+ return QObjectPrivate::get(obj)->isSignalConnected(signal_index) || (data && data->signalHasEndpoint(index));
+}
+
+/*
+ index MUST be the index returned by QMetaMethod::index()
+ This is different than the index returned by QObjectPrivate::signalIndex()
+*/
+bool QQmlData::signalHasEndpoint(int index)
+{
+ return notifyList && (notifyList->connectionMask & (1ULL << quint64(index % 64)));
+}
+
QQmlNotifier *QQmlData::objectNameNotifier() const
{
if (!extendedData) extendedData = new QQmlDataExtended;
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h
index 2356b2d122..04711ae3fc 100644
--- a/src/qml/qml/qqmlglobal_p.h
+++ b/src/qml/qml/qqmlglobal_p.h
@@ -89,6 +89,21 @@ QT_BEGIN_NAMESPACE
QMetaObject::connect(sender, signalIdx, receiver, methodIdx, Qt::DirectConnection); \
}
+bool Q_QML_EXPORT QQml_isSignalConnected(QObject*, int, int);
+
+#define IS_SIGNAL_CONNECTED(Sender, Signal) \
+do { \
+ QObject *sender = (Sender); \
+ const char *signal = (Signal); \
+ static int signalIdx = -1; \
+ static int methodIdx = -1; \
+ if (signalIdx < 0) { \
+ signalIdx = QObjectPrivate::get(sender)->signalIndex(signal); \
+ methodIdx = sender->metaObject()->indexOfSignal(signal); \
+ } \
+ return QQml_isSignalConnected(sender, signalIdx, methodIdx); \
+} while (0)
+
struct QQmlGraphics_DerivedObject : public QObject
{
void setParent_noEvent(QObject *parent) {