Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/types/qqmlbind.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||
2 | ** | - | ||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||
5 | ** | - | ||||||||||||||||||
6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||||||||||||||
7 | ** | - | ||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||
16 | ** | - | ||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||
24 | ** | - | ||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||
35 | ** | - | ||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
37 | ** | - | ||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||
39 | - | |||||||||||||||||||
40 | #include "qqmlbind_p.h" | - | ||||||||||||||||||
41 | - | |||||||||||||||||||
42 | #include <private/qqmlnullablevalue_p.h> | - | ||||||||||||||||||
43 | #include <private/qqmlproperty_p.h> | - | ||||||||||||||||||
44 | #include <private/qqmlbinding_p.h> | - | ||||||||||||||||||
45 | #include <private/qqmlmetatype_p.h> | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | #include <qqmlengine.h> | - | ||||||||||||||||||
48 | #include <qqmlcontext.h> | - | ||||||||||||||||||
49 | #include <qqmlproperty.h> | - | ||||||||||||||||||
50 | #include <qqmlinfo.h> | - | ||||||||||||||||||
51 | - | |||||||||||||||||||
52 | #include <QtCore/qfile.h> | - | ||||||||||||||||||
53 | #include <QtCore/qdebug.h> | - | ||||||||||||||||||
54 | #include <QtCore/qtimer.h> | - | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | #include <private/qobject_p.h> | - | ||||||||||||||||||
57 | - | |||||||||||||||||||
58 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
59 | - | |||||||||||||||||||
60 | class QQmlBindPrivate : public QObjectPrivate | - | ||||||||||||||||||
61 | { | - | ||||||||||||||||||
62 | public: | - | ||||||||||||||||||
63 | QQmlBindPrivate() : obj(nullptr), componentComplete(true), delayed(false), pendingEval(false) {} executed 36 times by 4 tests: end of block Executed by:
| 36 | ||||||||||||||||||
64 | ~QQmlBindPrivate() { } | - | ||||||||||||||||||
65 | - | |||||||||||||||||||
66 | QQmlNullableValue<bool> when; | - | ||||||||||||||||||
67 | QPointer<QObject> obj; | - | ||||||||||||||||||
68 | QString propName; | - | ||||||||||||||||||
69 | QQmlNullableValue<QVariant> value; | - | ||||||||||||||||||
70 | QQmlProperty prop; | - | ||||||||||||||||||
71 | QQmlAbstractBinding::Ptr prevBind; | - | ||||||||||||||||||
72 | bool componentComplete:1; | - | ||||||||||||||||||
73 | bool delayed:1; | - | ||||||||||||||||||
74 | bool pendingEval:1; | - | ||||||||||||||||||
75 | - | |||||||||||||||||||
76 | void validate(QObject *binding) const; | - | ||||||||||||||||||
77 | }; | - | ||||||||||||||||||
78 | - | |||||||||||||||||||
79 | void QQmlBindPrivate::validate(QObject *binding) const | - | ||||||||||||||||||
80 | { | - | ||||||||||||||||||
81 | if (!obj || (when.isValid() && !when))
| 4-30 | ||||||||||||||||||
82 | return; executed 20 times by 2 tests: return; Executed by:
| 20 | ||||||||||||||||||
83 | - | |||||||||||||||||||
84 | if (!prop.isValid()) {
| 2-18 | ||||||||||||||||||
85 | qmlWarning(binding) << "Property '" << propName << "' does not exist on " << QQmlMetaType::prettyTypeName(obj) << "."; | - | ||||||||||||||||||
86 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||
87 | } | - | ||||||||||||||||||
88 | - | |||||||||||||||||||
89 | if (!prop.isWritable()) {
| 2-16 | ||||||||||||||||||
90 | qmlWarning(binding) << "Property '" << propName << "' on " << QQmlMetaType::prettyTypeName(obj) << " is read-only."; | - | ||||||||||||||||||
91 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||
92 | } | - | ||||||||||||||||||
93 | } executed 16 times by 3 tests: end of block Executed by:
| 16 | ||||||||||||||||||
94 | - | |||||||||||||||||||
95 | /*! | - | ||||||||||||||||||
96 | \qmltype Binding | - | ||||||||||||||||||
97 | \instantiates QQmlBind | - | ||||||||||||||||||
98 | \inqmlmodule QtQml | - | ||||||||||||||||||
99 | \ingroup qtquick-interceptors | - | ||||||||||||||||||
100 | \brief Enables the arbitrary creation of property bindings. | - | ||||||||||||||||||
101 | - | |||||||||||||||||||
102 | In QML, property bindings result in a dependency between the properties of | - | ||||||||||||||||||
103 | different objects. | - | ||||||||||||||||||
104 | - | |||||||||||||||||||
105 | \section1 Binding to an Inaccessible Property | - | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | Sometimes it is necessary to bind an object's property to | - | ||||||||||||||||||
108 | that of another object that isn't directly instantiated by QML, such as a | - | ||||||||||||||||||
109 | property of a class exported to QML by C++. You can use the Binding type | - | ||||||||||||||||||
110 | to establish this dependency; binding any value to any object's property. | - | ||||||||||||||||||
111 | - | |||||||||||||||||||
112 | For example, in a C++ application that maps an "app.enteredText" property | - | ||||||||||||||||||
113 | into QML, you can use Binding to update the enteredText property. | - | ||||||||||||||||||
114 | - | |||||||||||||||||||
115 | \code | - | ||||||||||||||||||
116 | TextEdit { id: myTextField; text: "Please type here..." } | - | ||||||||||||||||||
117 | Binding { target: app; property: "enteredText"; value: myTextField.text } | - | ||||||||||||||||||
118 | \endcode | - | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | When \c{text} changes, the C++ property \c{enteredText} will update | - | ||||||||||||||||||
121 | automatically. | - | ||||||||||||||||||
122 | - | |||||||||||||||||||
123 | \section1 Conditional Bindings | - | ||||||||||||||||||
124 | - | |||||||||||||||||||
125 | In some cases you may want to modify the value of a property when a certain | - | ||||||||||||||||||
126 | condition is met but leave it unmodified otherwise. Often, it's not possible | - | ||||||||||||||||||
127 | to do this with direct bindings, as you have to supply values for all | - | ||||||||||||||||||
128 | possible branches. | - | ||||||||||||||||||
129 | - | |||||||||||||||||||
130 | For example, the code snippet below results in a warning whenever you | - | ||||||||||||||||||
131 | release the mouse. This is because the value of the binding is undefined | - | ||||||||||||||||||
132 | when the mouse isn't pressed. | - | ||||||||||||||||||
133 | - | |||||||||||||||||||
134 | \qml | - | ||||||||||||||||||
135 | // produces warning: "Unable to assign [undefined] to double value" | - | ||||||||||||||||||
136 | value: if (mouse.pressed) mouse.mouseX | - | ||||||||||||||||||
137 | \endqml | - | ||||||||||||||||||
138 | - | |||||||||||||||||||
139 | The Binding type can prevent this warning. | - | ||||||||||||||||||
140 | - | |||||||||||||||||||
141 | \qml | - | ||||||||||||||||||
142 | Binding on value { | - | ||||||||||||||||||
143 | when: mouse.pressed | - | ||||||||||||||||||
144 | value: mouse.mouseX | - | ||||||||||||||||||
145 | } | - | ||||||||||||||||||
146 | \endqml | - | ||||||||||||||||||
147 | - | |||||||||||||||||||
148 | The Binding type restores any previously set direct bindings on the | - | ||||||||||||||||||
149 | property. | - | ||||||||||||||||||
150 | - | |||||||||||||||||||
151 | \sa {Qt QML} | - | ||||||||||||||||||
152 | */ | - | ||||||||||||||||||
153 | QQmlBind::QQmlBind(QObject *parent) | - | ||||||||||||||||||
154 | : QObject(*(new QQmlBindPrivate), parent) | - | ||||||||||||||||||
155 | { | - | ||||||||||||||||||
156 | } executed 36 times by 4 tests: end of block Executed by:
| 36 | ||||||||||||||||||
157 | - | |||||||||||||||||||
158 | QQmlBind::~QQmlBind() | - | ||||||||||||||||||
159 | { | - | ||||||||||||||||||
160 | } | - | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | /*! | - | ||||||||||||||||||
163 | \qmlproperty bool QtQml::Binding::when | - | ||||||||||||||||||
164 | - | |||||||||||||||||||
165 | This property holds when the binding is active. | - | ||||||||||||||||||
166 | This should be set to an expression that evaluates to true when you want the binding to be active. | - | ||||||||||||||||||
167 | - | |||||||||||||||||||
168 | \code | - | ||||||||||||||||||
169 | Binding { | - | ||||||||||||||||||
170 | target: contactName; property: 'text' | - | ||||||||||||||||||
171 | value: name; when: list.ListView.isCurrentItem | - | ||||||||||||||||||
172 | } | - | ||||||||||||||||||
173 | \endcode | - | ||||||||||||||||||
174 | - | |||||||||||||||||||
175 | When the binding becomes inactive again, any direct bindings that were previously | - | ||||||||||||||||||
176 | set on the property will be restored. | - | ||||||||||||||||||
177 | */ | - | ||||||||||||||||||
178 | bool QQmlBind::when() const | - | ||||||||||||||||||
179 | { | - | ||||||||||||||||||
180 | Q_D(const QQmlBind); | - | ||||||||||||||||||
181 | return d->when; executed 4 times by 1 test: return d->when; Executed by:
| 4 | ||||||||||||||||||
182 | } | - | ||||||||||||||||||
183 | - | |||||||||||||||||||
184 | void QQmlBind::setWhen(bool v) | - | ||||||||||||||||||
185 | { | - | ||||||||||||||||||
186 | Q_D(QQmlBind); | - | ||||||||||||||||||
187 | if (!d->when.isNull && d->when == v)
| 14-32 | ||||||||||||||||||
188 | return; executed 14 times by 1 test: return; Executed by:
| 14 | ||||||||||||||||||
189 | - | |||||||||||||||||||
190 | d->when = v; | - | ||||||||||||||||||
191 | if (v && d->componentComplete)
| 0-22 | ||||||||||||||||||
192 | d->validate(this); executed 12 times by 1 test: d->validate(this); Executed by:
| 12 | ||||||||||||||||||
193 | eval(); | - | ||||||||||||||||||
194 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||
195 | - | |||||||||||||||||||
196 | /*! | - | ||||||||||||||||||
197 | \qmlproperty Object QtQml::Binding::target | - | ||||||||||||||||||
198 | - | |||||||||||||||||||
199 | The object to be updated. | - | ||||||||||||||||||
200 | */ | - | ||||||||||||||||||
201 | QObject *QQmlBind::object() | - | ||||||||||||||||||
202 | { | - | ||||||||||||||||||
203 | Q_D(const QQmlBind); | - | ||||||||||||||||||
204 | return d->obj; executed 4 times by 1 test: return d->obj; Executed by:
| 4 | ||||||||||||||||||
205 | } | - | ||||||||||||||||||
206 | - | |||||||||||||||||||
207 | void QQmlBind::setObject(QObject *obj) | - | ||||||||||||||||||
208 | { | - | ||||||||||||||||||
209 | Q_D(QQmlBind); | - | ||||||||||||||||||
210 | if (d->obj && d->when.isValid() && d->when) {
| 0 | ||||||||||||||||||
211 | /* if we switch the object at runtime, we need to restore the | - | ||||||||||||||||||
212 | previous binding on the old object before continuing */ | - | ||||||||||||||||||
213 | d->when = false; | - | ||||||||||||||||||
214 | eval(); | - | ||||||||||||||||||
215 | d->when = true; | - | ||||||||||||||||||
216 | } never executed: end of block | 0 | ||||||||||||||||||
217 | d->obj = obj; | - | ||||||||||||||||||
218 | if (d->componentComplete) {
| 0-26 | ||||||||||||||||||
219 | d->prop = QQmlProperty(d->obj, d->propName); | - | ||||||||||||||||||
220 | d->validate(this); | - | ||||||||||||||||||
221 | } never executed: end of block | 0 | ||||||||||||||||||
222 | eval(); | - | ||||||||||||||||||
223 | } executed 26 times by 3 tests: end of block Executed by:
| 26 | ||||||||||||||||||
224 | - | |||||||||||||||||||
225 | /*! | - | ||||||||||||||||||
226 | \qmlproperty string QtQml::Binding::property | - | ||||||||||||||||||
227 | - | |||||||||||||||||||
228 | The property to be updated. | - | ||||||||||||||||||
229 | - | |||||||||||||||||||
230 | This can be a group property if the expression results in accessing a | - | ||||||||||||||||||
231 | property of a \l {QML Basic Types}{value type}. For example: | - | ||||||||||||||||||
232 | - | |||||||||||||||||||
233 | \qml | - | ||||||||||||||||||
234 | Item { | - | ||||||||||||||||||
235 | id: item | - | ||||||||||||||||||
236 | - | |||||||||||||||||||
237 | property rect rectangle: Qt.rect(0, 0, 200, 200) | - | ||||||||||||||||||
238 | } | - | ||||||||||||||||||
239 | - | |||||||||||||||||||
240 | Binding { | - | ||||||||||||||||||
241 | target: item | - | ||||||||||||||||||
242 | property: "rectangle.x" | - | ||||||||||||||||||
243 | value: 100 | - | ||||||||||||||||||
244 | } | - | ||||||||||||||||||
245 | \endqml | - | ||||||||||||||||||
246 | */ | - | ||||||||||||||||||
247 | QString QQmlBind::property() const | - | ||||||||||||||||||
248 | { | - | ||||||||||||||||||
249 | Q_D(const QQmlBind); | - | ||||||||||||||||||
250 | return d->propName; executed 2 times by 1 test: return d->propName; Executed by:
| 2 | ||||||||||||||||||
251 | } | - | ||||||||||||||||||
252 | - | |||||||||||||||||||
253 | void QQmlBind::setProperty(const QString &p) | - | ||||||||||||||||||
254 | { | - | ||||||||||||||||||
255 | Q_D(QQmlBind); | - | ||||||||||||||||||
256 | if (!d->propName.isEmpty() && d->when.isValid() && d->when) {
| 0-26 | ||||||||||||||||||
257 | /* if we switch the property name at runtime, we need to restore the | - | ||||||||||||||||||
258 | previous binding on the old object before continuing */ | - | ||||||||||||||||||
259 | d->when = false; | - | ||||||||||||||||||
260 | eval(); | - | ||||||||||||||||||
261 | d->when = true; | - | ||||||||||||||||||
262 | } never executed: end of block | 0 | ||||||||||||||||||
263 | d->propName = p; | - | ||||||||||||||||||
264 | if (d->componentComplete) {
| 0-26 | ||||||||||||||||||
265 | d->prop = QQmlProperty(d->obj, d->propName); | - | ||||||||||||||||||
266 | d->validate(this); | - | ||||||||||||||||||
267 | } never executed: end of block | 0 | ||||||||||||||||||
268 | eval(); | - | ||||||||||||||||||
269 | } executed 26 times by 3 tests: end of block Executed by:
| 26 | ||||||||||||||||||
270 | - | |||||||||||||||||||
271 | /*! | - | ||||||||||||||||||
272 | \qmlproperty any QtQml::Binding::value | - | ||||||||||||||||||
273 | - | |||||||||||||||||||
274 | The value to be set on the target object and property. This can be a | - | ||||||||||||||||||
275 | constant (which isn't very useful), or a bound expression. | - | ||||||||||||||||||
276 | */ | - | ||||||||||||||||||
277 | QVariant QQmlBind::value() const | - | ||||||||||||||||||
278 | { | - | ||||||||||||||||||
279 | Q_D(const QQmlBind); | - | ||||||||||||||||||
280 | return d->value.value; executed 2 times by 1 test: return d->value.value; Executed by:
| 2 | ||||||||||||||||||
281 | } | - | ||||||||||||||||||
282 | - | |||||||||||||||||||
283 | void QQmlBind::setValue(const QVariant &v) | - | ||||||||||||||||||
284 | { | - | ||||||||||||||||||
285 | Q_D(QQmlBind); | - | ||||||||||||||||||
286 | d->value = v; | - | ||||||||||||||||||
287 | prepareEval(); | - | ||||||||||||||||||
288 | } executed 72 times by 3 tests: end of block Executed by:
| 72 | ||||||||||||||||||
289 | - | |||||||||||||||||||
290 | /*! | - | ||||||||||||||||||
291 | \qmlproperty bool QtQml::Binding::delayed | - | ||||||||||||||||||
292 | \since 5.8 | - | ||||||||||||||||||
293 | - | |||||||||||||||||||
294 | This property holds whether the binding should be delayed. | - | ||||||||||||||||||
295 | - | |||||||||||||||||||
296 | A delayed binding will not immediately update the target, but rather wait | - | ||||||||||||||||||
297 | until the event queue has been cleared. This can be used as an optimization, | - | ||||||||||||||||||
298 | or to prevent intermediary values from being assigned. | - | ||||||||||||||||||
299 | - | |||||||||||||||||||
300 | \code | - | ||||||||||||||||||
301 | Binding { | - | ||||||||||||||||||
302 | target: contactName; property: 'text' | - | ||||||||||||||||||
303 | value: givenName + " " + familyName; when: list.ListView.isCurrentItem | - | ||||||||||||||||||
304 | delayed: true | - | ||||||||||||||||||
305 | } | - | ||||||||||||||||||
306 | \endcode | - | ||||||||||||||||||
307 | */ | - | ||||||||||||||||||
308 | bool QQmlBind::delayed() const | - | ||||||||||||||||||
309 | { | - | ||||||||||||||||||
310 | Q_D(const QQmlBind); | - | ||||||||||||||||||
311 | return d->delayed; never executed: return d->delayed; | 0 | ||||||||||||||||||
312 | } | - | ||||||||||||||||||
313 | - | |||||||||||||||||||
314 | void QQmlBind::setDelayed(bool delayed) | - | ||||||||||||||||||
315 | { | - | ||||||||||||||||||
316 | Q_D(QQmlBind); | - | ||||||||||||||||||
317 | if (d->delayed == delayed)
| 0-2 | ||||||||||||||||||
318 | return; never executed: return; | 0 | ||||||||||||||||||
319 | - | |||||||||||||||||||
320 | d->delayed = delayed; | - | ||||||||||||||||||
321 | - | |||||||||||||||||||
322 | if (!d->delayed)
| 0-2 | ||||||||||||||||||
323 | eval(); never executed: eval(); | 0 | ||||||||||||||||||
324 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
325 | - | |||||||||||||||||||
326 | void QQmlBind::setTarget(const QQmlProperty &p) | - | ||||||||||||||||||
327 | { | - | ||||||||||||||||||
328 | Q_D(QQmlBind); | - | ||||||||||||||||||
329 | d->prop = p; | - | ||||||||||||||||||
330 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
331 | - | |||||||||||||||||||
332 | void QQmlBind::classBegin() | - | ||||||||||||||||||
333 | { | - | ||||||||||||||||||
334 | Q_D(QQmlBind); | - | ||||||||||||||||||
335 | d->componentComplete = false; | - | ||||||||||||||||||
336 | } executed 36 times by 4 tests: end of block Executed by:
| 36 | ||||||||||||||||||
337 | - | |||||||||||||||||||
338 | void QQmlBind::componentComplete() | - | ||||||||||||||||||
339 | { | - | ||||||||||||||||||
340 | Q_D(QQmlBind); | - | ||||||||||||||||||
341 | d->componentComplete = true; | - | ||||||||||||||||||
342 | if (!d->prop.isValid()) {
| 8-28 | ||||||||||||||||||
343 | d->prop = QQmlProperty(d->obj, d->propName); | - | ||||||||||||||||||
344 | d->validate(this); | - | ||||||||||||||||||
345 | } executed 28 times by 4 tests: end of block Executed by:
| 28 | ||||||||||||||||||
346 | eval(); | - | ||||||||||||||||||
347 | } executed 36 times by 4 tests: end of block Executed by:
| 36 | ||||||||||||||||||
348 | - | |||||||||||||||||||
349 | void QQmlBind::prepareEval() | - | ||||||||||||||||||
350 | { | - | ||||||||||||||||||
351 | Q_D(QQmlBind); | - | ||||||||||||||||||
352 | if (d->delayed) {
| 6-66 | ||||||||||||||||||
353 | if (!d->pendingEval)
| 2-4 | ||||||||||||||||||
354 | QTimer::singleShot(0, this, &QQmlBind::eval); executed 4 times by 1 test: QTimer::singleShot(0, this, &QQmlBind::eval); Executed by:
| 4 | ||||||||||||||||||
355 | d->pendingEval = true; | - | ||||||||||||||||||
356 | } else { executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
357 | eval(); | - | ||||||||||||||||||
358 | } executed 66 times by 3 tests: end of block Executed by:
| 66 | ||||||||||||||||||
359 | } | - | ||||||||||||||||||
360 | - | |||||||||||||||||||
361 | void QQmlBind::eval() | - | ||||||||||||||||||
362 | { | - | ||||||||||||||||||
363 | Q_D(QQmlBind); | - | ||||||||||||||||||
364 | d->pendingEval = false; | - | ||||||||||||||||||
365 | if (!d->prop.isValid() || d->value.isNull || !d->componentComplete)
| 6-98 | ||||||||||||||||||
366 | return; executed 106 times by 4 tests: return; Executed by:
| 106 | ||||||||||||||||||
367 | - | |||||||||||||||||||
368 | if (d->when.isValid()) {
| 20-66 | ||||||||||||||||||
369 | if (!d->when) {
| 26-40 | ||||||||||||||||||
370 | //restore any previous binding | - | ||||||||||||||||||
371 | if (d->prevBind) {
| 6-34 | ||||||||||||||||||
372 | QQmlAbstractBinding::Ptr p = d->prevBind; | - | ||||||||||||||||||
373 | d->prevBind = nullptr; | - | ||||||||||||||||||
374 | QQmlPropertyPrivate::setBinding(p.data()); | - | ||||||||||||||||||
375 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
376 | return; executed 40 times by 1 test: return; Executed by:
| 40 | ||||||||||||||||||
377 | } | - | ||||||||||||||||||
378 | - | |||||||||||||||||||
379 | //save any set binding for restoration | - | ||||||||||||||||||
380 | if (!d->prevBind)
| 12-14 | ||||||||||||||||||
381 | d->prevBind = QQmlPropertyPrivate::binding(d->prop); executed 12 times by 1 test: d->prevBind = QQmlPropertyPrivate::binding(d->prop); Executed by:
| 12 | ||||||||||||||||||
382 | QQmlPropertyPrivate::removeBinding(d->prop); | - | ||||||||||||||||||
383 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||
384 | - | |||||||||||||||||||
385 | d->prop.write(d->value.value); | - | ||||||||||||||||||
386 | } executed 46 times by 3 tests: end of block Executed by:
| 46 | ||||||||||||||||||
387 | - | |||||||||||||||||||
388 | QT_END_NAMESPACE | - | ||||||||||||||||||
389 | - | |||||||||||||||||||
390 | #include "moc_qqmlbind_p.cpp" | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |