Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmlconnections.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | class QQmlConnectionsPrivate : public QObjectPrivate | - | ||||||||||||||||||
8 | { | - | ||||||||||||||||||
9 | public: | - | ||||||||||||||||||
10 | QQmlConnectionsPrivate() : target(nullptr), enabled(true), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {} executed 136 times by 10 tests: end of block Executed by:
| 136 | ||||||||||||||||||
11 | - | |||||||||||||||||||
12 | QList<QQmlBoundSignal*> boundsignals; | - | ||||||||||||||||||
13 | QObject *target; | - | ||||||||||||||||||
14 | - | |||||||||||||||||||
15 | bool enabled; | - | ||||||||||||||||||
16 | bool targetSet; | - | ||||||||||||||||||
17 | bool ignoreUnknownSignals; | - | ||||||||||||||||||
18 | bool componentcomplete; | - | ||||||||||||||||||
19 | - | |||||||||||||||||||
20 | QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit; | - | ||||||||||||||||||
21 | QList<const QV4::CompiledData::Binding *> bindings; | - | ||||||||||||||||||
22 | }; | - | ||||||||||||||||||
23 | QQmlConnections::QQmlConnections(QObject *parent) : | - | ||||||||||||||||||
24 | QObject(*(new QQmlConnectionsPrivate), parent) | - | ||||||||||||||||||
25 | { | - | ||||||||||||||||||
26 | } executed 136 times by 10 tests: end of block Executed by:
| 136 | ||||||||||||||||||
27 | - | |||||||||||||||||||
28 | QQmlConnections::~QQmlConnections() | - | ||||||||||||||||||
29 | { | - | ||||||||||||||||||
30 | } | - | ||||||||||||||||||
31 | QObject *QQmlConnections::target() const | - | ||||||||||||||||||
32 | { | - | ||||||||||||||||||
33 | const QQmlConnectionsPrivate * const d = d_func(); | - | ||||||||||||||||||
34 | return executed 266 times by 9 tests: d->targetSet ? d->target : parent();return d->targetSet ? d->target : parent(); Executed by:
executed 266 times by 9 tests: return d->targetSet ? d->target : parent(); Executed by:
| 266 | ||||||||||||||||||
35 | } | - | ||||||||||||||||||
36 | - | |||||||||||||||||||
37 | class QQmlBoundSignalDeleter : public QObject | - | ||||||||||||||||||
38 | { | - | ||||||||||||||||||
39 | public: | - | ||||||||||||||||||
40 | QQmlBoundSignalDeleter(QQmlBoundSignal *signal) : m_signal(signal) { m_signal->removeFromObject(); } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
41 | ~QQmlBoundSignalDeleter() { delete m_signal; } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
42 | - | |||||||||||||||||||
43 | private: | - | ||||||||||||||||||
44 | QQmlBoundSignal *m_signal; | - | ||||||||||||||||||
45 | }; | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | void QQmlConnections::setTarget(QObject *obj) | - | ||||||||||||||||||
48 | { | - | ||||||||||||||||||
49 | QQmlConnectionsPrivate * const d = d_func(); | - | ||||||||||||||||||
50 | if (d->targetSet
| 0-122 | ||||||||||||||||||
51 | return; never executed: return; | 0 | ||||||||||||||||||
52 | d->targetSet = true; | - | ||||||||||||||||||
53 | for (QQmlBoundSignal *s : qAsConst(d->boundsignals)) { | - | ||||||||||||||||||
54 | - | |||||||||||||||||||
55 | - | |||||||||||||||||||
56 | if (s->isNotifying()
| 2 | ||||||||||||||||||
57 | (new executed 2 times by 1 test: QQmlBoundSignalDeleter(s))->deleteLater();(new QQmlBoundSignalDeleter(s))->deleteLater(); Executed by:
executed 2 times by 1 test: (new QQmlBoundSignalDeleter(s))->deleteLater(); Executed by:
| 2 | ||||||||||||||||||
58 | else | - | ||||||||||||||||||
59 | delete s; executed 2 times by 1 test: delete s; Executed by:
| 2 | ||||||||||||||||||
60 | } | - | ||||||||||||||||||
61 | d->boundsignals.clear(); | - | ||||||||||||||||||
62 | d->target = obj; | - | ||||||||||||||||||
63 | connectSignals(); | - | ||||||||||||||||||
64 | targetChanged(); | - | ||||||||||||||||||
65 | } executed 128 times by 9 tests: end of block Executed by:
| 128 | ||||||||||||||||||
66 | bool QQmlConnections::isEnabled() const | - | ||||||||||||||||||
67 | { | - | ||||||||||||||||||
68 | const QQmlConnectionsPrivate * const d = d_func(); | - | ||||||||||||||||||
69 | return never executed: d->enabled;return d->enabled; never executed: return d->enabled; | 0 | ||||||||||||||||||
70 | } | - | ||||||||||||||||||
71 | - | |||||||||||||||||||
72 | void QQmlConnections::setEnabled(bool enabled) | - | ||||||||||||||||||
73 | { | - | ||||||||||||||||||
74 | QQmlConnectionsPrivate * const d = d_func(); | - | ||||||||||||||||||
75 | if (d->enabled == enabled
| 0-6 | ||||||||||||||||||
76 | return; never executed: return; | 0 | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | d->enabled = enabled; | - | ||||||||||||||||||
79 | - | |||||||||||||||||||
80 | for (QQmlBoundSignal *s : qAsConst(d->boundsignals)) | - | ||||||||||||||||||
81 | s->setEnabled(d->enabled); executed 4 times by 1 test: s->setEnabled(d->enabled); Executed by:
| 4 | ||||||||||||||||||
82 | - | |||||||||||||||||||
83 | enabledChanged(); | - | ||||||||||||||||||
84 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
85 | bool QQmlConnections::ignoreUnknownSignals() const | - | ||||||||||||||||||
86 | { | - | ||||||||||||||||||
87 | const QQmlConnectionsPrivate * const d = d_func(); | - | ||||||||||||||||||
88 | return executed 2 times by 1 test: d->ignoreUnknownSignals;return d->ignoreUnknownSignals; Executed by:
executed 2 times by 1 test: return d->ignoreUnknownSignals; Executed by:
| 2 | ||||||||||||||||||
89 | } | - | ||||||||||||||||||
90 | - | |||||||||||||||||||
91 | void QQmlConnections::setIgnoreUnknownSignals(bool ignore) | - | ||||||||||||||||||
92 | { | - | ||||||||||||||||||
93 | QQmlConnectionsPrivate * const d = d_func(); | - | ||||||||||||||||||
94 | d->ignoreUnknownSignals = ignore; | - | ||||||||||||||||||
95 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
96 | - | |||||||||||||||||||
97 | void QQmlConnectionsParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) | - | ||||||||||||||||||
98 | { | - | ||||||||||||||||||
99 | for (int ii = 0; ii < props.count()
| 130-146 | ||||||||||||||||||
100 | const QV4::CompiledData::Binding *binding = props.at(ii); | - | ||||||||||||||||||
101 | const QString &propName = qmlUnit->stringAt(binding->propertyNameIndex); | - | ||||||||||||||||||
102 | - | |||||||||||||||||||
103 | if (!propName.startsWith(QLatin1String("on"))
| 2-144 | ||||||||||||||||||
104 | error(props.at(ii), QQmlConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName)); | - | ||||||||||||||||||
105 | return; executed 6 times by 1 test: return; Executed by:
| 6 | ||||||||||||||||||
106 | } | - | ||||||||||||||||||
107 | - | |||||||||||||||||||
108 | if (binding->type >= QV4::CompiledData::Binding::Type_Object
| 4-136 | ||||||||||||||||||
109 | const QV4::CompiledData::Object *target = qmlUnit->objectAt(binding->value.objectIndex); | - | ||||||||||||||||||
110 | if (!qmlUnit->stringAt(target->inheritedTypeNameIndex).isEmpty()
| 2 | ||||||||||||||||||
111 | error(binding, QQmlConnections::tr("Connections: nested objects not allowed")); executed 2 times by 1 test: error(binding, QQmlConnections::tr("Connections: nested objects not allowed")); Executed by:
| 2 | ||||||||||||||||||
112 | else | - | ||||||||||||||||||
113 | error(binding, QQmlConnections::tr("Connections: syntax error")); executed 2 times by 1 test: error(binding, QQmlConnections::tr("Connections: syntax error")); Executed by:
| 2 | ||||||||||||||||||
114 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||
115 | } if (binding->type != QV4::CompiledData::Binding::Type_Script
| 0-136 | ||||||||||||||||||
116 | error(binding, QQmlConnections::tr("Connections: script expected")); | - | ||||||||||||||||||
117 | return; never executed: return; | 0 | ||||||||||||||||||
118 | } | - | ||||||||||||||||||
119 | } executed 136 times by 9 tests: end of block Executed by:
| 136 | ||||||||||||||||||
120 | } executed 130 times by 9 tests: end of block Executed by:
| 130 | ||||||||||||||||||
121 | - | |||||||||||||||||||
122 | void QQmlConnectionsParser::applyBindings(QObject *object, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) | - | ||||||||||||||||||
123 | { | - | ||||||||||||||||||
124 | QQmlConnectionsPrivate *p = | - | ||||||||||||||||||
125 | static_cast<QQmlConnectionsPrivate *>(QObjectPrivate::get(object)); | - | ||||||||||||||||||
126 | p->compilationUnit = compilationUnit; | - | ||||||||||||||||||
127 | p->bindings = bindings; | - | ||||||||||||||||||
128 | } executed 132 times by 9 tests: end of block Executed by:
| 132 | ||||||||||||||||||
129 | - | |||||||||||||||||||
130 | void QQmlConnections::connectSignals() | - | ||||||||||||||||||
131 | { | - | ||||||||||||||||||
132 | QQmlConnectionsPrivate * const d = d_func(); | - | ||||||||||||||||||
133 | if (!d->componentcomplete
| 8-144 | ||||||||||||||||||
134 | return; executed 128 times by 9 tests: return; Executed by:
| 128 | ||||||||||||||||||
135 | - | |||||||||||||||||||
136 | if (d->bindings.isEmpty()
| 4-132 | ||||||||||||||||||
137 | return; executed 4 times by 2 tests: return; Executed by:
| 4 | ||||||||||||||||||
138 | QObject *target = this->target(); | - | ||||||||||||||||||
139 | QQmlData *ddata = QQmlData::get(this); | - | ||||||||||||||||||
140 | QQmlContextData *ctxtdata = ddata
| 0-132 | ||||||||||||||||||
141 | - | |||||||||||||||||||
142 | const QV4::CompiledData::Unit *qmlUnit = d->compilationUnit->data; | - | ||||||||||||||||||
143 | for (const QV4::CompiledData::Binding *binding : qAsConst(d->bindings)) { | - | ||||||||||||||||||
144 | ((binding->type == QV4::CompiledData::Binding::Type_Script) ? static_cast<void>(0) : qt_assert("binding->type == QV4::CompiledData::Binding::Type_Script", __FILE__, 281)); | - | ||||||||||||||||||
145 | QString propName = qmlUnit->stringAt(binding->propertyNameIndex); | - | ||||||||||||||||||
146 | - | |||||||||||||||||||
147 | QQmlProperty prop(target, propName); | - | ||||||||||||||||||
148 | if (prop.isValid()
| 0-130 | ||||||||||||||||||
149 | int signalIndex = QQmlPropertyPrivate::get(prop)->signalIndex(); | - | ||||||||||||||||||
150 | QQmlBoundSignal *signal = | - | ||||||||||||||||||
151 | new QQmlBoundSignal(target, signalIndex, this, qmlEngine(this)); | - | ||||||||||||||||||
152 | signal->setEnabled(d->enabled); | - | ||||||||||||||||||
153 | - | |||||||||||||||||||
154 | auto f = d->compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex]; | - | ||||||||||||||||||
155 | QQmlBoundSignalExpression *expression = | - | ||||||||||||||||||
156 | ctxtdata
| 0-130 | ||||||||||||||||||
157 | : nullptr; | - | ||||||||||||||||||
158 | signal->takeExpression(expression); | - | ||||||||||||||||||
159 | d->boundsignals += signal; | - | ||||||||||||||||||
160 | } executed 130 times by 9 tests: else {end of block Executed by:
| 130 | ||||||||||||||||||
161 | if (!d->ignoreUnknownSignals
| 4 | ||||||||||||||||||
162 | qmlWarning(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); executed 4 times by 1 test: qmlWarning(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); Executed by:
| 4 | ||||||||||||||||||
163 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
164 | } | - | ||||||||||||||||||
165 | } executed 132 times by 9 tests: end of block Executed by:
| 132 | ||||||||||||||||||
166 | - | |||||||||||||||||||
167 | void QQmlConnections::classBegin() | - | ||||||||||||||||||
168 | { | - | ||||||||||||||||||
169 | QQmlConnectionsPrivate * const d = d_func(); | - | ||||||||||||||||||
170 | d->componentcomplete=false; | - | ||||||||||||||||||
171 | } executed 136 times by 10 tests: end of block Executed by:
| 136 | ||||||||||||||||||
172 | - | |||||||||||||||||||
173 | void QQmlConnections::componentComplete() | - | ||||||||||||||||||
174 | { | - | ||||||||||||||||||
175 | QQmlConnectionsPrivate * const d = d_func(); | - | ||||||||||||||||||
176 | d->componentcomplete=true; | - | ||||||||||||||||||
177 | connectSignals(); | - | ||||||||||||||||||
178 | } executed 136 times by 10 tests: end of block Executed by:
| 136 | ||||||||||||||||||
179 | - | |||||||||||||||||||
180 | - | |||||||||||||||||||
181 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |