Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/designer/qquickdesignersupportitems.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | static void (*fixResourcePathsForObjectCallBack)(QObject*) = nullptr; | - | ||||||||||||
7 | - | |||||||||||||
8 | static void stopAnimation(QObject *object) | - | ||||||||||||
9 | { | - | ||||||||||||
10 | if (object == nullptr
| 0-6 | ||||||||||||
11 | return; never executed: return; | 0 | ||||||||||||
12 | - | |||||||||||||
13 | QQuickTransition *transition = qobject_cast<QQuickTransition*>(object); | - | ||||||||||||
14 | QQuickAbstractAnimation *animation = qobject_cast<QQuickAbstractAnimation*>(object); | - | ||||||||||||
15 | QQmlTimer *timer = qobject_cast<QQmlTimer*>(object); | - | ||||||||||||
16 | if (transition
| 0-6 | ||||||||||||
17 | transition->setFromState(QString()); | - | ||||||||||||
18 | transition->setToState(QString()); | - | ||||||||||||
19 | } never executed: else if (animationend of block
| 0-6 | ||||||||||||
20 | - | |||||||||||||
21 | - | |||||||||||||
22 | - | |||||||||||||
23 | animation->setLoops(1); | - | ||||||||||||
24 | animation->complete(); | - | ||||||||||||
25 | animation->setDisableUserControl(); | - | ||||||||||||
26 | } never executed: else if (timerend of block
| 0-6 | ||||||||||||
27 | timer->blockSignals(true); | - | ||||||||||||
28 | } never executed: end of block | 0 | ||||||||||||
29 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
30 | - | |||||||||||||
31 | static void makeLoaderSynchronous(QObject *object) | - | ||||||||||||
32 | { | - | ||||||||||||
33 | if (QQuickLoader *loader = qobject_cast<QQuickLoader*>(object)
| 0-6 | ||||||||||||
34 | loader->setAsynchronous(false); never executed: loader->setAsynchronous(false); | 0 | ||||||||||||
35 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
36 | - | |||||||||||||
37 | static void allSubObjects(QObject *object, QObjectList &objectList) | - | ||||||||||||
38 | { | - | ||||||||||||
39 | - | |||||||||||||
40 | if (!object
| 0-6 | ||||||||||||
41 | return; executed 6 times by 1 test: return; Executed by:
| 6 | ||||||||||||
42 | - | |||||||||||||
43 | objectList.append(object); | - | ||||||||||||
44 | - | |||||||||||||
45 | const QMetaObject *mo = object->metaObject(); | - | ||||||||||||
46 | - | |||||||||||||
47 | QByteArrayList deferredPropertyNames; | - | ||||||||||||
48 | const int namesIndex = mo->indexOfClassInfo("DeferredPropertyNames"); | - | ||||||||||||
49 | if (namesIndex != -1
| 0-6 | ||||||||||||
50 | QMetaClassInfo classInfo = mo->classInfo(namesIndex); | - | ||||||||||||
51 | deferredPropertyNames = QByteArray(classInfo.value()).split(','); | - | ||||||||||||
52 | } never executed: end of block | 0 | ||||||||||||
53 | - | |||||||||||||
54 | for (int index = QObject::staticMetaObject.propertyOffset(); | - | ||||||||||||
55 | index < object->metaObject()->propertyCount()
| 6-254 | ||||||||||||
56 | index++) { | - | ||||||||||||
57 | - | |||||||||||||
58 | QMetaProperty metaProperty = object->metaObject()->property(index); | - | ||||||||||||
59 | - | |||||||||||||
60 | if (deferredPropertyNames.contains(metaProperty.name())
| 0-254 | ||||||||||||
61 | continue; never executed: continue; | 0 | ||||||||||||
62 | - | |||||||||||||
63 | - | |||||||||||||
64 | if (metaProperty.isReadable()
| 0-254 | ||||||||||||
65 | && metaProperty.isWritable()
| 114-140 | ||||||||||||
66 | && QQmlMetaType::isQObject(metaProperty.userType())
| 12-128 | ||||||||||||
67 | if (qstrcmp(metaProperty.name(), "parent")
| 6 | ||||||||||||
68 | QObject *propertyObject = QQmlMetaType::toQObject(metaProperty.read(object)); | - | ||||||||||||
69 | allSubObjects(propertyObject, objectList); | - | ||||||||||||
70 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
71 | - | |||||||||||||
72 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||||||||
73 | - | |||||||||||||
74 | - | |||||||||||||
75 | if (metaProperty.isReadable()
| 0-254 | ||||||||||||
76 | && QQmlMetaType::isList(metaProperty.userType())
| 42-212 | ||||||||||||
77 | QQmlListReference list(object, metaProperty.name()); | - | ||||||||||||
78 | if (list.canCount()
| 0-42 | ||||||||||||
79 | for (int i = 0; i < list.count()
| 0-42 | ||||||||||||
80 | QObject *propertyObject = list.at(i); | - | ||||||||||||
81 | allSubObjects(propertyObject, objectList); | - | ||||||||||||
82 | - | |||||||||||||
83 | } never executed: end of block | 0 | ||||||||||||
84 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||
85 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||
86 | } executed 254 times by 1 test: end of block Executed by:
| 254 | ||||||||||||
87 | - | |||||||||||||
88 | - | |||||||||||||
89 | for (QObject *childObject : object->children()) { | - | ||||||||||||
90 | allSubObjects(childObject, objectList); | - | ||||||||||||
91 | } never executed: end of block | 0 | ||||||||||||
92 | - | |||||||||||||
93 | - | |||||||||||||
94 | QQuickItem *quickItem = qobject_cast<QQuickItem*>(object); | - | ||||||||||||
95 | if (quickItem
| 0-6 | ||||||||||||
96 | const auto childItems = quickItem->childItems(); | - | ||||||||||||
97 | for (QQuickItem *childItem : childItems) | - | ||||||||||||
98 | allSubObjects(childItem, objectList); never executed: allSubObjects(childItem, objectList); | 0 | ||||||||||||
99 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
100 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
101 | - | |||||||||||||
102 | void QQuickDesignerSupportItems::tweakObjects(QObject *object) | - | ||||||||||||
103 | { | - | ||||||||||||
104 | QObjectList objectList; | - | ||||||||||||
105 | allSubObjects(object, objectList); | - | ||||||||||||
106 | for (QObject* childObject : qAsConst(objectList)) { | - | ||||||||||||
107 | stopAnimation(childObject); | - | ||||||||||||
108 | makeLoaderSynchronous(childObject); | - | ||||||||||||
109 | if (fixResourcePathsForObjectCallBack
| 2-4 | ||||||||||||
110 | fixResourcePathsForObjectCallBack(childObject); executed 2 times by 1 test: fixResourcePathsForObjectCallBack(childObject); Executed by:
| 2 | ||||||||||||
111 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
112 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||
113 | - | |||||||||||||
114 | static QObject *createDummyWindow(QQmlEngine *engine) | - | ||||||||||||
115 | { | - | ||||||||||||
116 | QQmlComponent component(engine, QUrl(([]() noexcept -> QString { enum { Size = sizeof(u"" "qrc:/qtquickplugin/mockfiles/Window.qml")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "qrc:/qtquickplugin/mockfiles/Window.qml" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp; never executed: }())));return qstring_literal_temp; | 0 | ||||||||||||
117 | return never executed: component.create();return component.create(); never executed: return component.create(); | 0 | ||||||||||||
118 | } | - | ||||||||||||
119 | - | |||||||||||||
120 | static bool isWindowMetaObject(const QMetaObject *metaObject) | - | ||||||||||||
121 | { | - | ||||||||||||
122 | if (metaObject
| 2-4 | ||||||||||||
123 | if (metaObject->className() == ([]() -> QByteArray { enum { Size = sizeof("QWindow") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "QWindow" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return executed 4 times by 1 test: ba;return ba; Executed by:
executed 4 times by 1 test: }())return ba; Executed by:
| 0-4 | ||||||||||||
124 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
125 | - | |||||||||||||
126 | return executed 4 times by 1 test: isWindowMetaObject(metaObject->superClass());return isWindowMetaObject(metaObject->superClass()); Executed by:
executed 4 times by 1 test: return isWindowMetaObject(metaObject->superClass()); Executed by:
| 4 | ||||||||||||
127 | } | - | ||||||||||||
128 | - | |||||||||||||
129 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||
130 | } | - | ||||||||||||
131 | - | |||||||||||||
132 | static bool isWindow(QObject *object) { | - | ||||||||||||
133 | if (object
| 0-2 | ||||||||||||
134 | return executed 2 times by 1 test: isWindowMetaObject(object->metaObject());return isWindowMetaObject(object->metaObject()); Executed by:
executed 2 times by 1 test: return isWindowMetaObject(object->metaObject()); Executed by:
| 2 | ||||||||||||
135 | - | |||||||||||||
136 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
137 | } | - | ||||||||||||
138 | - | |||||||||||||
139 | static bool isCrashingType(const QQmlType &type) | - | ||||||||||||
140 | { | - | ||||||||||||
141 | QString name = type.qmlTypeName(); | - | ||||||||||||
142 | - | |||||||||||||
143 | if (type.qmlTypeName() == QLatin1String("QtMultimedia/MediaPlayer")
| 0-2 | ||||||||||||
144 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
145 | - | |||||||||||||
146 | if (type.qmlTypeName() == QLatin1String("QtMultimedia/Audio")
| 0-2 | ||||||||||||
147 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
148 | - | |||||||||||||
149 | if (type.qmlTypeName() == QLatin1String("QtQuick.Controls/MenuItem")
| 0-2 | ||||||||||||
150 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
151 | - | |||||||||||||
152 | if (type.qmlTypeName() == QLatin1String("QtQuick.Controls/Menu")
| 0-2 | ||||||||||||
153 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
154 | - | |||||||||||||
155 | if (type.qmlTypeName() == QLatin1String("QtQuick/Timer")
| 0-2 | ||||||||||||
156 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
157 | - | |||||||||||||
158 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||
159 | } | - | ||||||||||||
160 | - | |||||||||||||
161 | QObject *QQuickDesignerSupportItems::createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context) | - | ||||||||||||
162 | { | - | ||||||||||||
163 | ComponentCompleteDisabler disableComponentComplete; | - | ||||||||||||
164 | - | |||||||||||||
165 | (void)disableComponentComplete; | - | ||||||||||||
166 | - | |||||||||||||
167 | QObject *object = nullptr; | - | ||||||||||||
168 | QQmlType type = QQmlMetaType::qmlType(typeName, majorNumber, minorNumber); | - | ||||||||||||
169 | - | |||||||||||||
170 | if (isCrashingType(type)
| 0-2 | ||||||||||||
171 | object = new QObject; | - | ||||||||||||
172 | } never executed: else if (type.isValid()end of block
| 0-2 | ||||||||||||
173 | if ( type.isComposite()
| 0-2 | ||||||||||||
174 | object = createComponent(type.sourceUrl(), context); | - | ||||||||||||
175 | } never executed: elseend of block | 0 | ||||||||||||
176 | { | - | ||||||||||||
177 | if (type.typeName() == "QQmlComponent"
| 0-2 | ||||||||||||
178 | object = new QQmlComponent(context->engine(), nullptr); | - | ||||||||||||
179 | } never executed: else {end of block | 0 | ||||||||||||
180 | object = type.create(); | - | ||||||||||||
181 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
182 | } | - | ||||||||||||
183 | - | |||||||||||||
184 | if (isWindow(object)
| 0-2 | ||||||||||||
185 | delete object; | - | ||||||||||||
186 | object = createDummyWindow(context->engine()); | - | ||||||||||||
187 | } never executed: end of block | 0 | ||||||||||||
188 | - | |||||||||||||
189 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
190 | - | |||||||||||||
191 | if (!object
| 0-2 | ||||||||||||
192 | QMessageLogger(__FILE__, 244, __PRETTY_FUNCTION__).warning() << "QuickDesigner: Cannot create an object of type" | - | ||||||||||||
193 | << QString::fromLatin1("%1 %2,%3").arg(typeName).arg(majorNumber).arg(minorNumber) | - | ||||||||||||
194 | << "- type isn't known to declarative meta type system"; | - | ||||||||||||
195 | } never executed: end of block | 0 | ||||||||||||
196 | - | |||||||||||||
197 | tweakObjects(object); | - | ||||||||||||
198 | - | |||||||||||||
199 | if (object
| 0-2 | ||||||||||||
200 | QQmlEngine::setContextForObject(object, context); executed 2 times by 1 test: QQmlEngine::setContextForObject(object, context); Executed by:
| 2 | ||||||||||||
201 | - | |||||||||||||
202 | QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); | - | ||||||||||||
203 | - | |||||||||||||
204 | return executed 2 times by 1 test: object;return object; Executed by:
executed 2 times by 1 test: return object; Executed by:
| 2 | ||||||||||||
205 | } | - | ||||||||||||
206 | - | |||||||||||||
207 | QObject *QQuickDesignerSupportItems::createComponent(const QUrl &componentUrl, QQmlContext *context) | - | ||||||||||||
208 | { | - | ||||||||||||
209 | ComponentCompleteDisabler disableComponentComplete; | - | ||||||||||||
210 | (void)disableComponentComplete; | - | ||||||||||||
211 | - | |||||||||||||
212 | QQmlComponent component(context->engine(), componentUrl); | - | ||||||||||||
213 | - | |||||||||||||
214 | QObject *object = component.beginCreate(context); | - | ||||||||||||
215 | tweakObjects(object); | - | ||||||||||||
216 | component.completeCreate(); | - | ||||||||||||
217 | QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); | - | ||||||||||||
218 | - | |||||||||||||
219 | if (component.isError()
| 0-2 | ||||||||||||
220 | QMessageLogger(__FILE__, 272, __PRETTY_FUNCTION__).warning() << "Error in:" << __PRETTY_FUNCTION__ << componentUrl; | - | ||||||||||||
221 | const auto errors = component.errors(); | - | ||||||||||||
222 | for (const QQmlError &error : errors) | - | ||||||||||||
223 | QMessageLogger(__FILE__, 275, __PRETTY_FUNCTION__).warning() << error; never executed: QMessageLogger(__FILE__, 275, __PRETTY_FUNCTION__).warning() << error; | 0 | ||||||||||||
224 | } never executed: end of block | 0 | ||||||||||||
225 | return executed 2 times by 1 test: object;return object; Executed by:
executed 2 times by 1 test: return object; Executed by:
| 2 | ||||||||||||
226 | } | - | ||||||||||||
227 | - | |||||||||||||
228 | bool QQuickDesignerSupportItems::objectWasDeleted(QObject *object) | - | ||||||||||||
229 | { | - | ||||||||||||
230 | return never executed: QObjectPrivate::get(object)->wasDeleted;return QObjectPrivate::get(object)->wasDeleted; never executed: return QObjectPrivate::get(object)->wasDeleted; | 0 | ||||||||||||
231 | } | - | ||||||||||||
232 | - | |||||||||||||
233 | void QQuickDesignerSupportItems::disableNativeTextRendering(QQuickItem *item) | - | ||||||||||||
234 | { | - | ||||||||||||
235 | QQuickText *text = qobject_cast<QQuickText*>(item); | - | ||||||||||||
236 | if (text
| 0 | ||||||||||||
237 | text->setRenderType(QQuickText::QtRendering); never executed: text->setRenderType(QQuickText::QtRendering); | 0 | ||||||||||||
238 | - | |||||||||||||
239 | QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(item); | - | ||||||||||||
240 | if (textInput
| 0 | ||||||||||||
241 | textInput->setRenderType(QQuickTextInput::QtRendering); never executed: textInput->setRenderType(QQuickTextInput::QtRendering); | 0 | ||||||||||||
242 | - | |||||||||||||
243 | QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(item); | - | ||||||||||||
244 | if (textEdit
| 0 | ||||||||||||
245 | textEdit->setRenderType(QQuickTextEdit::QtRendering); never executed: textEdit->setRenderType(QQuickTextEdit::QtRendering); | 0 | ||||||||||||
246 | } never executed: end of block | 0 | ||||||||||||
247 | - | |||||||||||||
248 | void QQuickDesignerSupportItems::disableTextCursor(QQuickItem *item) | - | ||||||||||||
249 | { | - | ||||||||||||
250 | const auto childItems = item->childItems(); | - | ||||||||||||
251 | for (QQuickItem *childItem : childItems) | - | ||||||||||||
252 | disableTextCursor(childItem); never executed: disableTextCursor(childItem); | 0 | ||||||||||||
253 | - | |||||||||||||
254 | QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(item); | - | ||||||||||||
255 | if (textInput
| 0 | ||||||||||||
256 | textInput->setCursorVisible(false); never executed: textInput->setCursorVisible(false); | 0 | ||||||||||||
257 | - | |||||||||||||
258 | QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(item); | - | ||||||||||||
259 | if (textEdit
| 0 | ||||||||||||
260 | textEdit->setCursorVisible(false); never executed: textEdit->setCursorVisible(false); | 0 | ||||||||||||
261 | } never executed: end of block | 0 | ||||||||||||
262 | - | |||||||||||||
263 | void QQuickDesignerSupportItems::disableTransition(QObject *object) | - | ||||||||||||
264 | { | - | ||||||||||||
265 | QQuickTransition *transition = qobject_cast<QQuickTransition*>(object); | - | ||||||||||||
266 | ((transition) ? static_cast<void>(0) : qt_assert("transition", __FILE__, 318)); | - | ||||||||||||
267 | const QString invalidState = QLatin1String("invalidState"); | - | ||||||||||||
268 | transition->setToState(invalidState); | - | ||||||||||||
269 | transition->setFromState(invalidState); | - | ||||||||||||
270 | } never executed: end of block | 0 | ||||||||||||
271 | - | |||||||||||||
272 | void QQuickDesignerSupportItems::disableBehaivour(QObject *object) | - | ||||||||||||
273 | { | - | ||||||||||||
274 | QQuickBehavior* behavior = qobject_cast<QQuickBehavior*>(object); | - | ||||||||||||
275 | ((behavior) ? static_cast<void>(0) : qt_assert("behavior", __FILE__, 327)); | - | ||||||||||||
276 | behavior->setEnabled(false); | - | ||||||||||||
277 | } never executed: end of block | 0 | ||||||||||||
278 | - | |||||||||||||
279 | void QQuickDesignerSupportItems::stopUnifiedTimer() | - | ||||||||||||
280 | { | - | ||||||||||||
281 | QUnifiedTimer::instance()->setSlowdownFactor(0.00001); | - | ||||||||||||
282 | QUnifiedTimer::instance()->setSlowModeEnabled(true); | - | ||||||||||||
283 | } never executed: end of block | 0 | ||||||||||||
284 | - | |||||||||||||
285 | void QQuickDesignerSupportItems::registerFixResourcePathsForObjectCallBack(void (*callback)(QObject *)) | - | ||||||||||||
286 | { | - | ||||||||||||
287 | fixResourcePathsForObjectCallBack = callback; | - | ||||||||||||
288 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
289 | - | |||||||||||||
290 | - | |||||||||||||
Switch to Source code | Preprocessed file |