Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmldelayedcallqueue.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | - | |||||||
6 | - | |||||||
7 | - | |||||||
8 | - | |||||||
9 | void QQmlDelayedCallQueue::DelayedFunctionCall::execute(QV4::ExecutionEngine *engine) const | - | ||||||
10 | { | - | ||||||
11 | if (!m_guarded
| 0-94 | ||||||
12 | (!m_objectGuard.isNull()
| 12-82 | ||||||
13 | !QQmlData::wasDeleted(m_objectGuard)
| 0-82 | ||||||
14 | QQmlData::get(m_objectGuard)
| 0-82 | ||||||
15 | !QQmlData::get(m_objectGuard)->isQueuedForDeletion
| 0-82 | ||||||
16 | - | |||||||
17 | QV4::Scope scope(engine); | - | ||||||
18 | - | |||||||
19 | QV4::ArrayObject *array = m_args.as<QV4::ArrayObject>(); | - | ||||||
20 | const QV4::FunctionObject *callback = m_function.as<QV4::FunctionObject>(); | - | ||||||
21 | ((callback) ? static_cast<void>(0) : qt_assert("callback", __FILE__, 68)); | - | ||||||
22 | const int argCount = array
| 6-76 | ||||||
23 | QV4::JSCallData jsCallData(scope, argCount); | - | ||||||
24 | *jsCallData->thisObject = QV4::Encode::undefined(); | - | ||||||
25 | - | |||||||
26 | for (int i = 0; i < argCount
| 10-82 | ||||||
27 | jsCallData->args[i] = array->get(i); | - | ||||||
28 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||
29 | - | |||||||
30 | callback->call(jsCallData); | - | ||||||
31 | - | |||||||
32 | if (scope.engine->hasException
| 2-80 | ||||||
33 | QQmlError error = scope.engine->catchExceptionAsQmlError(); | - | ||||||
34 | error.setDescription(error.description() + QLatin1String(" (exception occurred during delayed function evaluation)")); | - | ||||||
35 | QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error); | - | ||||||
36 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||
37 | } executed 82 times by 2 tests: end of block Executed by:
| 82 | ||||||
38 | } executed 94 times by 2 tests: end of block Executed by:
| 94 | ||||||
39 | - | |||||||
40 | - | |||||||
41 | - | |||||||
42 | - | |||||||
43 | - | |||||||
44 | QQmlDelayedCallQueue::QQmlDelayedCallQueue() | - | ||||||
45 | : QObject(nullptr), m_engine(nullptr), m_callbackOutstanding(false) | - | ||||||
46 | { | - | ||||||
47 | } executed 11448 times by 151 tests: end of block Executed by:
| 11448 | ||||||
48 | - | |||||||
49 | QQmlDelayedCallQueue::~QQmlDelayedCallQueue() | - | ||||||
50 | { | - | ||||||
51 | } | - | ||||||
52 | - | |||||||
53 | void QQmlDelayedCallQueue::init(QV4::ExecutionEngine* engine) | - | ||||||
54 | { | - | ||||||
55 | m_engine = engine; | - | ||||||
56 | - | |||||||
57 | const QMetaObject &metaObject = QQmlDelayedCallQueue::staticMetaObject; | - | ||||||
58 | int methodIndex = metaObject.indexOfSlot("ticked()"); | - | ||||||
59 | m_tickedMethod = metaObject.method(methodIndex); | - | ||||||
60 | } executed 11448 times by 151 tests: end of block Executed by:
| 11448 | ||||||
61 | - | |||||||
62 | QV4::ReturnedValue QQmlDelayedCallQueue::addUniquelyAndExecuteLater(const QV4::FunctionObject *b, const QV4::Value *, const QV4::Value *argv, int argc) | - | ||||||
63 | { | - | ||||||
64 | QV4::Scope scope(b); | - | ||||||
65 | if (argc == 0
| 0-454 | ||||||
66 | return never executed: scope.engine->throwError(QString::fromUtf8("Qt.callLater: no arguments given"));return scope.engine->throwError(QString::fromUtf8("Qt.callLater: no arguments given")); never executed: return scope.engine->throwError(QString::fromUtf8("Qt.callLater: no arguments given")); | 0 | ||||||
67 | - | |||||||
68 | const QV4::FunctionObject *func = argv[0].as<QV4::FunctionObject>(); | - | ||||||
69 | - | |||||||
70 | if (!func
| 0-454 | ||||||
71 | return never executed: scope.engine->throwError(QString::fromUtf8("Qt.callLater: first argument not a function or signal"));return scope.engine->throwError(QString::fromUtf8("Qt.callLater: first argument not a function or signal")); never executed: return scope.engine->throwError(QString::fromUtf8("Qt.callLater: first argument not a function or signal")); | 0 | ||||||
72 | - | |||||||
73 | QPair<QObject *, int> functionData = QV4::QObjectMethod::extractQtMethod(func); | - | ||||||
74 | QV4::ReturnedValue arg0 = argc
| 0-454 | ||||||
75 | - | |||||||
76 | QVector<DelayedFunctionCall>::Iterator iter; | - | ||||||
77 | if (functionData.second != -1
| 218-236 | ||||||
78 | - | |||||||
79 | iter = m_delayedFunctionCalls.begin(); | - | ||||||
80 | while (iter != m_delayedFunctionCalls.end()
| 42-410 | ||||||
81 | DelayedFunctionCall& dfc = *iter; | - | ||||||
82 | QPair<QObject *, int> storedFunctionData = QV4::QObjectMethod::extractQtMethod(dfc.m_function.as<QV4::FunctionObject>()); | - | ||||||
83 | if (storedFunctionData == functionData
| 194-216 | ||||||
84 | break; executed 194 times by 1 test: break; Executed by:
| 194 | ||||||
85 | } | - | ||||||
86 | ++iter; | - | ||||||
87 | } executed 216 times by 1 test: end of block Executed by:
| 216 | ||||||
88 | } executed 236 times by 1 test: else {end of block Executed by:
| 236 | ||||||
89 | - | |||||||
90 | iter = m_delayedFunctionCalls.begin(); | - | ||||||
91 | while (iter != m_delayedFunctionCalls.end()
| 62-500 | ||||||
92 | DelayedFunctionCall& dfc = *iter; | - | ||||||
93 | if (arg0 == dfc.m_function.value()
| 156-344 | ||||||
94 | break; executed 156 times by 2 tests: break; Executed by:
| 156 | ||||||
95 | } | - | ||||||
96 | ++iter; | - | ||||||
97 | } executed 344 times by 1 test: end of block Executed by:
| 344 | ||||||
98 | } executed 218 times by 2 tests: end of block Executed by:
| 218 | ||||||
99 | - | |||||||
100 | const bool functionAlreadyStored = (iter != m_delayedFunctionCalls.end()); | - | ||||||
101 | if (functionAlreadyStored
| 104-350 | ||||||
102 | DelayedFunctionCall dfc = *iter; | - | ||||||
103 | m_delayedFunctionCalls.erase(iter); | - | ||||||
104 | m_delayedFunctionCalls.append(dfc); | - | ||||||
105 | } executed 350 times by 2 tests: else {end of block Executed by:
| 350 | ||||||
106 | m_delayedFunctionCalls.append(QV4::PersistentValue(m_engine, arg0)); | - | ||||||
107 | } executed 104 times by 2 tests: end of block Executed by:
| 104 | ||||||
108 | - | |||||||
109 | DelayedFunctionCall& dfc = m_delayedFunctionCalls.last(); | - | ||||||
110 | if (dfc.m_objectGuard.isNull()
| 104-350 | ||||||
111 | if (functionData.second != -1
| 42-62 | ||||||
112 | - | |||||||
113 | dfc.m_objectGuard = QQmlGuard<QObject>(functionData.first); | - | ||||||
114 | dfc.m_guarded = true; | - | ||||||
115 | } executed 42 times by 1 test: else if (func->scope()->type == QV4::Heap::ExecutionContext::Type_QmlContextend of block Executed by:
| 2-60 | ||||||
116 | QV4::QmlContext::Data *g = static_cast<QV4::QmlContext::Data *>(func->scope()); | - | ||||||
117 | ((g->qml()->scopeObject) ? static_cast<void>(0) : qt_assert("g->qml()->scopeObject", __FILE__, 164)); | - | ||||||
118 | dfc.m_objectGuard = QQmlGuard<QObject>(g->qml()->scopeObject); | - | ||||||
119 | dfc.m_guarded = true; | - | ||||||
120 | } executed 60 times by 2 tests: end of block Executed by:
| 60 | ||||||
121 | } executed 104 times by 2 tests: end of block Executed by:
| 104 | ||||||
122 | storeAnyArguments(dfc, argv, argc, 1, m_engine); | - | ||||||
123 | - | |||||||
124 | if (!m_callbackOutstanding
| 24-430 | ||||||
125 | m_tickedMethod.invoke(this, Qt::QueuedConnection); | - | ||||||
126 | m_callbackOutstanding = true; | - | ||||||
127 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||
128 | return executed 454 times by 2 tests: QV4::Encode::undefined();return QV4::Encode::undefined(); Executed by:
executed 454 times by 2 tests: return QV4::Encode::undefined(); Executed by:
| 454 | ||||||
129 | } | - | ||||||
130 | - | |||||||
131 | void QQmlDelayedCallQueue::storeAnyArguments(DelayedFunctionCall &dfc, const QV4::Value *argv, int argc, int offset, QV4::ExecutionEngine *engine) | - | ||||||
132 | { | - | ||||||
133 | const int length = argc - offset; | - | ||||||
134 | if (length == 0
| 12-442 | ||||||
135 | dfc.m_args.clear(); | - | ||||||
136 | return; executed 442 times by 2 tests: return; Executed by:
| 442 | ||||||
137 | } | - | ||||||
138 | QV4::Scope scope(engine); | - | ||||||
139 | QV4::ScopedArrayObject array(scope, engine->newArrayObject(length)); | - | ||||||
140 | uint i = 0; | - | ||||||
141 | for (int j = offset, ej = argc; j < ej
| 12-24 | ||||||
142 | array->put(i, argv[j]); executed 24 times by 1 test: array->put(i, argv[j]); Executed by:
| 24 | ||||||
143 | dfc.m_args.set(engine, array); | - | ||||||
144 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||
145 | - | |||||||
146 | void QQmlDelayedCallQueue::executeAllExpired_Later() | - | ||||||
147 | { | - | ||||||
148 | - | |||||||
149 | - | |||||||
150 | QVector<DelayedFunctionCall> delayedCalls = m_delayedFunctionCalls; | - | ||||||
151 | m_delayedFunctionCalls.clear(); | - | ||||||
152 | - | |||||||
153 | QVector<DelayedFunctionCall>::Iterator iter = delayedCalls.begin(); | - | ||||||
154 | while (iter != delayedCalls.end()
| 22-94 | ||||||
155 | DelayedFunctionCall& dfc = *iter; | - | ||||||
156 | dfc.execute(m_engine); | - | ||||||
157 | ++iter; | - | ||||||
158 | } executed 94 times by 2 tests: end of block Executed by:
| 94 | ||||||
159 | } executed 22 times by 2 tests: end of block Executed by:
| 22 | ||||||
160 | - | |||||||
161 | void QQmlDelayedCallQueue::ticked() | - | ||||||
162 | { | - | ||||||
163 | m_callbackOutstanding = false; | - | ||||||
164 | executeAllExpired_Later(); | - | ||||||
165 | } executed 22 times by 2 tests: end of block Executed by:
| 22 | ||||||
166 | - | |||||||
167 | - | |||||||
168 | - | |||||||
Switch to Source code | Preprocessed file |