Provide receivers count from QQmlData.
Change-Id: I70b06507158797df3083dc23a119935497aa19f4 Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
This commit is contained in:
parent
22408c96cd
commit
955bac4940
|
@ -91,12 +91,14 @@ public:
|
||||||
QAbstractDeclarativeData::parentChanged = parentChanged;
|
QAbstractDeclarativeData::parentChanged = parentChanged;
|
||||||
QAbstractDeclarativeData::objectNameChanged = objectNameChanged;
|
QAbstractDeclarativeData::objectNameChanged = objectNameChanged;
|
||||||
QAbstractDeclarativeData::signalEmitted = signalEmitted;
|
QAbstractDeclarativeData::signalEmitted = signalEmitted;
|
||||||
|
QAbstractDeclarativeData::receivers = receivers;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyed(QAbstractDeclarativeData *, QObject *);
|
static void destroyed(QAbstractDeclarativeData *, QObject *);
|
||||||
static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *);
|
static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *);
|
||||||
static void objectNameChanged(QAbstractDeclarativeData *, QObject *);
|
static void objectNameChanged(QAbstractDeclarativeData *, QObject *);
|
||||||
static void signalEmitted(QAbstractDeclarativeData *, QObject *, int, void **);
|
static void signalEmitted(QAbstractDeclarativeData *, QObject *, int, void **);
|
||||||
|
static int receivers(QAbstractDeclarativeData *, const QObject *, int);
|
||||||
|
|
||||||
void destroyed(QObject *);
|
void destroyed(QObject *);
|
||||||
void parentChanged(QObject *, QObject *);
|
void parentChanged(QObject *, QObject *);
|
||||||
|
@ -130,6 +132,7 @@ public:
|
||||||
|
|
||||||
inline QQmlNotifierEndpoint *notify(int index);
|
inline QQmlNotifierEndpoint *notify(int index);
|
||||||
void addNotify(int index, QQmlNotifierEndpoint *);
|
void addNotify(int index, QQmlNotifierEndpoint *);
|
||||||
|
int endpointCount(int index);
|
||||||
|
|
||||||
// The context that created the C++ object
|
// The context that created the C++ object
|
||||||
QQmlContextData *context;
|
QQmlContextData *context;
|
||||||
|
|
|
@ -457,6 +457,25 @@ void QQmlData::signalEmitted(QAbstractDeclarativeData *, QObject *object, int in
|
||||||
if (ep) QQmlNotifier::emitNotify(ep);
|
if (ep) QQmlNotifier::emitNotify(ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QQmlData::receivers(QAbstractDeclarativeData *d, const QObject *, int index)
|
||||||
|
{
|
||||||
|
return static_cast<QQmlData *>(d)->endpointCount(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int QQmlData::endpointCount(int index)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
QQmlNotifierEndpoint *ep = notify(index);
|
||||||
|
if (!ep)
|
||||||
|
return count;
|
||||||
|
++count;
|
||||||
|
while (ep->next) {
|
||||||
|
++count;
|
||||||
|
ep = ep->next;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
void QQmlEnginePrivate::init()
|
void QQmlEnginePrivate::init()
|
||||||
{
|
{
|
||||||
Q_Q(QQmlEngine);
|
Q_Q(QQmlEngine);
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import Test 1.0
|
||||||
|
|
||||||
|
MyReceiversTestObject {
|
||||||
|
property int dummy: prop
|
||||||
|
onPropChanged: { var a = 0; } //do nothing
|
||||||
|
onMySignal: { var a = 0; } //do nothing
|
||||||
|
}
|
||||||
|
|
|
@ -81,6 +81,8 @@ void registerTypes()
|
||||||
qmlRegisterType<MyEnum1Class>("Test",1,0,"MyEnum1Class");
|
qmlRegisterType<MyEnum1Class>("Test",1,0,"MyEnum1Class");
|
||||||
qmlRegisterType<MyEnum2Class>("Test",1,0,"MyEnum2Class");
|
qmlRegisterType<MyEnum2Class>("Test",1,0,"MyEnum2Class");
|
||||||
qmlRegisterType<MyEnumDerivedClass>("Test",1,0,"MyEnumDerivedClass");
|
qmlRegisterType<MyEnumDerivedClass>("Test",1,0,"MyEnumDerivedClass");
|
||||||
|
|
||||||
|
qmlRegisterType<MyReceiversTestObject>("Test",1,0,"MyReceiversTestObject");
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant myCustomVariantTypeConverter(const QString &data)
|
QVariant myCustomVariantTypeConverter(const QString &data)
|
||||||
|
|
|
@ -526,6 +526,24 @@ public:
|
||||||
UnavailableType() {}
|
UnavailableType() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MyReceiversTestObject : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(int prop READ prop NOTIFY propChanged)
|
||||||
|
public:
|
||||||
|
MyReceiversTestObject() {}
|
||||||
|
|
||||||
|
int prop() const { return 5; }
|
||||||
|
|
||||||
|
int mySignalCount() { return receivers(SIGNAL(mySignal())); }
|
||||||
|
int propChangedCount() { return receivers(SIGNAL(propChanged())); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void mySignal();
|
||||||
|
void propChanged();
|
||||||
|
};
|
||||||
|
|
||||||
class MyDotPropertyObject : public QObject
|
class MyDotPropertyObject : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -907,6 +925,7 @@ QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
|
||||||
QML_DECLARE_TYPE(MyRevisionedClass)
|
QML_DECLARE_TYPE(MyRevisionedClass)
|
||||||
QML_DECLARE_TYPE(MyRevisionedSubclass)
|
QML_DECLARE_TYPE(MyRevisionedSubclass)
|
||||||
QML_DECLARE_TYPE(MySubclass)
|
QML_DECLARE_TYPE(MySubclass)
|
||||||
|
QML_DECLARE_TYPE(MyReceiversTestObject)
|
||||||
|
|
||||||
void registerTypes();
|
void registerTypes();
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,7 @@ private slots:
|
||||||
void nestedComponentRoots();
|
void nestedComponentRoots();
|
||||||
void registrationOrder();
|
void registrationOrder();
|
||||||
void readonly();
|
void readonly();
|
||||||
|
void receivers();
|
||||||
|
|
||||||
void basicRemote_data();
|
void basicRemote_data();
|
||||||
void basicRemote();
|
void basicRemote();
|
||||||
|
@ -2285,6 +2286,18 @@ void tst_qqmllanguage::readonly()
|
||||||
delete o;
|
delete o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_qqmllanguage::receivers()
|
||||||
|
{
|
||||||
|
QQmlComponent component(&engine, TEST_FILE("receivers.qml"));
|
||||||
|
|
||||||
|
MyReceiversTestObject *o = qobject_cast<MyReceiversTestObject*>(component.create());
|
||||||
|
QVERIFY(o != 0);
|
||||||
|
QCOMPARE(o->mySignalCount(), 1);
|
||||||
|
QCOMPARE(o->propChangedCount(), 2);
|
||||||
|
|
||||||
|
delete o;
|
||||||
|
}
|
||||||
|
|
||||||
// QTBUG-18268
|
// QTBUG-18268
|
||||||
void tst_qqmllanguage::remoteLoadCrash()
|
void tst_qqmllanguage::remoteLoadCrash()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue