OpenCoverage

qquickdesignercustomobjectdata.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/designer/qquickdesignercustomobjectdata.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7typedef QHash<QObject*, QQuickDesignerCustomObjectData*> CustomObjectDataHash;-
8namespace { namespace Q_QGS_s_designerObjectToDataHash { typedef CustomObjectDataHash Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
executed 2 times by 1 test: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qquickdesignersupport
}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return
executed 42 times by 1 test: return &holder.value;
Executed by:
  • tst_qquickdesignersupport
&holder.value;
executed 42 times by 1 test: return &holder.value;
Executed by:
  • tst_qquickdesignersupport
} } } static QGlobalStatic<CustomObjectDataHash, Q_QGS_s_designerObjectToDataHash::innerFunction, Q_QGS_s_designerObjectToDataHash::guard> s_designerObjectToDataHash;
0-42
9-
10struct HandleDestroyedFunctor {-
11 QQuickDesignerCustomObjectData *data;-
12 void operator()() { data->handleDestroyed(); }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
4
13};-
14-
15QQuickDesignerCustomObjectData::QQuickDesignerCustomObjectData(QObject *object)-
16 : m_object(object)-
17{-
18 if (object
objectDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEnever evaluated
) {
0-4
19 populateResetHashes();-
20 s_designerObjectToDataHash()->insert(object, this);-
21-
22 HandleDestroyedFunctor functor;-
23 functor.data = this;-
24 QObject::connect(object, &QObject::destroyed, functor);-
25 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
4
26}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
4
27-
28void QQuickDesignerCustomObjectData::registerData(QObject *object)-
29{-
30 new QQuickDesignerCustomObjectData(object);-
31}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
4
32-
33QQuickDesignerCustomObjectData *QQuickDesignerCustomObjectData::get(QObject *object)-
34{-
35 return
executed 34 times by 1 test: return s_designerObjectToDataHash()->value(object);
Executed by:
  • tst_qquickdesignersupport
s_designerObjectToDataHash()->value(object);
executed 34 times by 1 test: return s_designerObjectToDataHash()->value(object);
Executed by:
  • tst_qquickdesignersupport
34
36}-
37-
38QVariant QQuickDesignerCustomObjectData::getResetValue(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName)-
39{-
40 QQuickDesignerCustomObjectData* data = get(object);-
41-
42 if (data
dataDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
)
4
43 return
executed 4 times by 1 test: return data->getResetValue(propertyName);
Executed by:
  • tst_qquickdesignersupport
data->getResetValue(propertyName);
executed 4 times by 1 test: return data->getResetValue(propertyName);
Executed by:
  • tst_qquickdesignersupport
4
44-
45 return
executed 4 times by 1 test: return QVariant();
Executed by:
  • tst_qquickdesignersupport
QVariant();
executed 4 times by 1 test: return QVariant();
Executed by:
  • tst_qquickdesignersupport
4
46}-
47-
48void QQuickDesignerCustomObjectData::doResetProperty(QObject *object, QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName)-
49{-
50 QQuickDesignerCustomObjectData* data = get(object);-
51-
52 if (data
dataDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEnever evaluated
)
0-8
53 data->doResetProperty(context, propertyName);
executed 8 times by 1 test: data->doResetProperty(context, propertyName);
Executed by:
  • tst_qquickdesignersupport
8
54}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
8
55-
56bool QQuickDesignerCustomObjectData::hasValidResetBinding(QObject *object, const QQuickDesignerSupport::PropertyName &propertyName)-
57{-
58 QQuickDesignerCustomObjectData* data = get(object);-
59-
60 if (data
dataDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEnever evaluated
)
0-2
61 return
executed 2 times by 1 test: return data->hasValidResetBinding(propertyName);
Executed by:
  • tst_qquickdesignersupport
data->hasValidResetBinding(propertyName);
executed 2 times by 1 test: return data->hasValidResetBinding(propertyName);
Executed by:
  • tst_qquickdesignersupport
2
62-
63 return
never executed: return false;
false;
never executed: return false;
0
64}-
65-
66bool QQuickDesignerCustomObjectData::hasBindingForProperty(QObject *object,-
67 QQmlContext *context,-
68 const QQuickDesignerSupport::PropertyName &propertyName,-
69 bool *hasChanged)-
70{-
71 QQuickDesignerCustomObjectData* data = get(object);-
72-
73 if (data
dataDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEnever evaluated
)
0-12
74 return
executed 12 times by 1 test: return data->hasBindingForProperty(context, propertyName, hasChanged);
Executed by:
  • tst_qquickdesignersupport
data->hasBindingForProperty(context, propertyName, hasChanged);
executed 12 times by 1 test: return data->hasBindingForProperty(context, propertyName, hasChanged);
Executed by:
  • tst_qquickdesignersupport
12
75-
76 return
never executed: return false;
false;
never executed: return false;
0
77}-
78-
79void QQuickDesignerCustomObjectData::setPropertyBinding(QObject *object,-
80 QQmlContext *context,-
81 const QQuickDesignerSupport::PropertyName &propertyName,-
82 const QString &expression)-
83{-
84 QQuickDesignerCustomObjectData* data = get(object);-
85-
86 if (data
dataDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEnever evaluated
)
0-4
87 data->setPropertyBinding(context, propertyName, expression);
executed 4 times by 1 test: data->setPropertyBinding(context, propertyName, expression);
Executed by:
  • tst_qquickdesignersupport
4
88}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
4
89-
90void QQuickDesignerCustomObjectData::keepBindingFromGettingDeleted(QObject *object,-
91 QQmlContext *context,-
92 const QQuickDesignerSupport::PropertyName &propertyName)-
93{-
94 QQuickDesignerCustomObjectData* data = get(object);-
95-
96 if (data
dataDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
97 data->keepBindingFromGettingDeleted(context, propertyName);
never executed: data->keepBindingFromGettingDeleted(context, propertyName);
0
98}
never executed: end of block
0
99-
100void QQuickDesignerCustomObjectData::populateResetHashes()-
101{-
102 const QQuickDesignerSupport::PropertyNameList propertyNameList =-
103 QQuickDesignerSupportProperties::propertyNameListForWritableProperties(object());-
104-
105 const QMetaObject *mo = object()->metaObject();-
106 QByteArrayList deferredPropertyNames;-
107 const int namesIndex = mo->indexOfClassInfo("DeferredPropertyNames");-
108 if (namesIndex != -1
namesIndex != -1Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
) {
0-4
109 QMetaClassInfo classInfo = mo->classInfo(namesIndex);-
110 deferredPropertyNames = QByteArray(classInfo.value()).split(',');-
111 }
never executed: end of block
0
112-
113 for (const QQuickDesignerSupport::PropertyName &propertyName : propertyNameList) {-
114-
115 if (deferredPropertyNames.contains(propertyName)
deferredProper...(propertyName)Description
TRUEnever evaluated
FALSEevaluated 240 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
)
0-240
116 continue;
never executed: continue;
0
117-
118 QQmlProperty property(object(), QString::fromUtf8(propertyName), QQmlEngine::contextForObject(object()));-
119-
120 QQmlAbstractBinding::Ptr binding = QQmlAbstractBinding::Ptr(QQmlPropertyPrivate::binding(property));-
121-
122 if (binding
bindingDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEevaluated 238 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
) {
2-238
123 m_resetBindingHash.insert(propertyName, binding);-
124 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
else if (property.isWritable()
property.isWritable()Description
TRUEevaluated 214 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
) {
2-214
125 m_resetValueHash.insert(propertyName, property.read());-
126 }
executed 214 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
214
127 }
executed 240 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
240
128}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
4
129-
130QObject *QQuickDesignerCustomObjectData::object() const-
131{-
132 return
executed 516 times by 1 test: return m_object;
Executed by:
  • tst_qquickdesignersupport
m_object;
executed 516 times by 1 test: return m_object;
Executed by:
  • tst_qquickdesignersupport
516
133}-
134-
135QVariant QQuickDesignerCustomObjectData::getResetValue(const QQuickDesignerSupport::PropertyName &propertyName) const-
136{-
137 return
executed 4 times by 1 test: return m_resetValueHash.value(propertyName);
Executed by:
  • tst_qquickdesignersupport
m_resetValueHash.value(propertyName);
executed 4 times by 1 test: return m_resetValueHash.value(propertyName);
Executed by:
  • tst_qquickdesignersupport
4
138}-
139-
140void QQuickDesignerCustomObjectData::doResetProperty(QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName)-
141{-
142 QQmlProperty property(object(), QString::fromUtf8(propertyName), context);-
143-
144 if (!property.isValid()
!property.isValid()Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
)
0-8
145 return;
never executed: return;
0
146-
147 QQmlAbstractBinding *binding = QQmlPropertyPrivate::binding(property);-
148 if (binding
bindingDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
&& !(hasValidResetBinding(propertyName)
hasValidResetB...(propertyName)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
&& getResetBinding(propertyName) == binding
getResetBindin...me) == bindingDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
)) {
0-4
149 binding->setEnabled(false, nullptr);-
150 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
4
151-
152-
153 if (hasValidResetBinding(propertyName)
hasValidResetB...(propertyName)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
) {
4
154 QQmlAbstractBinding *binding = getResetBinding(propertyName);-
155-
156-
157-
158-
159 QQmlBinding *qmlBinding = dynamic_cast<QQmlBinding*>(binding);-
160-
161 if (qmlBinding
qmlBindingDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEnever evaluated
)
0-4
162 qmlBinding->setTarget(property);
executed 4 times by 1 test: qmlBinding->setTarget(property);
Executed by:
  • tst_qquickdesignersupport
4
163 QQmlPropertyPrivate::setBinding(binding, QQmlPropertyPrivate::None, QQmlPropertyData::DontRemoveBinding);-
164 if (qmlBinding
qmlBindingDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEnever evaluated
)
0-4
165 qmlBinding->update();
executed 4 times by 1 test: qmlBinding->update();
Executed by:
  • tst_qquickdesignersupport
4
166-
167 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
else if (property.isResettable()
property.isResettable()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEnever evaluated
) {
0-4
168 property.reset();-
169 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
else if (property.propertyTypeCategory() == QQmlProperty::List
property.prope...Property::ListDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0-4
170 QQmlListReference list = qvariant_cast<QQmlListReference>(property.read());-
171-
172 if (!QQuickDesignerSupportProperties::hasFullImplementedListInterface(list)
!QQuickDesigne...nterface(list)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
173 QMessageLogger(__FILE__, 219, __PRETTY_FUNCTION__).warning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!";-
174 return;
never executed: return;
0
175 }-
176-
177 list.clear();-
178 }
never executed: end of block
else if (property.isWritable()
property.isWritable()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
179 if (property.read() == getResetValue(propertyName)
property.read(...(propertyName)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
180 return;
never executed: return;
0
181-
182 property.write(getResetValue(propertyName));-
183 }
never executed: end of block
0
184}
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
8
185-
186bool QQuickDesignerCustomObjectData::hasValidResetBinding(const QQuickDesignerSupport::PropertyName &propertyName) const-
187{-
188 return
executed 14 times by 1 test: return m_resetBindingHash.contains(propertyName) && m_resetBindingHash.value(propertyName).data();
Executed by:
  • tst_qquickdesignersupport
m_resetBindingHash.contains(propertyName) && m_resetBindingHash.value(propertyName).data();
executed 14 times by 1 test: return m_resetBindingHash.contains(propertyName) && m_resetBindingHash.value(propertyName).data();
Executed by:
  • tst_qquickdesignersupport
14
189}-
190-
191QQmlAbstractBinding *QQuickDesignerCustomObjectData::getResetBinding(const QQuickDesignerSupport::PropertyName &propertyName) const-
192{-
193 return
executed 6 times by 1 test: return m_resetBindingHash.value(propertyName).data();
Executed by:
  • tst_qquickdesignersupport
m_resetBindingHash.value(propertyName).data();
executed 6 times by 1 test: return m_resetBindingHash.value(propertyName).data();
Executed by:
  • tst_qquickdesignersupport
6
194}-
195-
196bool QQuickDesignerCustomObjectData::hasBindingForProperty(QQmlContext *context,-
197 const QQuickDesignerSupport::PropertyName &propertyName,-
198 bool *hasChanged) const-
199{-
200 if (QQuickDesignerSupportProperties::isPropertyBlackListed(propertyName)
QQuickDesigner...(propertyName)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
)
0-12
201 return
never executed: return false;
false;
never executed: return false;
0
202-
203 QQmlProperty property(object(), QString::fromUtf8(propertyName), context);-
204-
205 bool hasBinding = QQmlPropertyPrivate::binding(property);-
206-
207 if (hasChanged
hasChangedDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
) {
0-12
208 *hasChanged = hasBinding != m_hasBindingHash.value(propertyName, false);-
209 if (*
*hasChangedDescription
TRUEnever evaluated
FALSEnever evaluated
hasChanged
*hasChangedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
210 m_hasBindingHash.insert(propertyName, hasBinding);
never executed: m_hasBindingHash.insert(propertyName, hasBinding);
0
211 }
never executed: end of block
0
212-
213 return
executed 12 times by 1 test: return QQmlPropertyPrivate::binding(property);
Executed by:
  • tst_qquickdesignersupport
QQmlPropertyPrivate::binding(property);
executed 12 times by 1 test: return QQmlPropertyPrivate::binding(property);
Executed by:
  • tst_qquickdesignersupport
12
214}-
215-
216void QQuickDesignerCustomObjectData::setPropertyBinding(QQmlContext *context,-
217 const QQuickDesignerSupport::PropertyName &propertyName,-
218 const QString &expression)-
219{-
220 QQmlProperty property(object(), QString::fromUtf8(propertyName), context);-
221-
222 if (!property.isValid()
!property.isValid()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
)
0-4
223 return;
never executed: return;
0
224-
225 if (property.isProperty()
property.isProperty()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
FALSEnever evaluated
) {
0-4
226 QQmlBinding *binding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core,-
227 expression, object(), QQmlContextData::get(context));-
228 binding->setTarget(property);-
229 binding->setNotifyOnValueChanged(true);-
230-
231 QQmlPropertyPrivate::setBinding(binding, QQmlPropertyPrivate::None, QQmlPropertyData::DontRemoveBinding);-
232-
233 binding->update();-
234 if (binding->hasError()
binding->hasError()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickdesignersupport
) {
0-4
235 if (property.property().userType() == QVariant::String
property.prope...ariant::StringDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
236 property.write(QVariant(QLatin1Char('#') + expression + QLatin1Char('#')));
never executed: property.write(QVariant(QLatin1Char('#') + expression + QLatin1Char('#')));
0
237 }
never executed: end of block
0
238-
239 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
else {
4
240 QMessageLogger(__FILE__, 286, __PRETTY_FUNCTION__).warning() << __PRETTY_FUNCTION__ << ": Cannot set binding for property" << propertyName << ": property is unknown for type";-
241 }
never executed: end of block
0
242}-
243-
244void QQuickDesignerCustomObjectData::keepBindingFromGettingDeleted(QQmlContext *context,-
245 const QQuickDesignerSupport::PropertyName &propertyName)-
246{-
247-
248 (void)context;-
249 (void)propertyName;-
250}
never executed: end of block
0
251-
252void QQuickDesignerCustomObjectData::handleDestroyed()-
253{-
254 s_designerObjectToDataHash()->remove(m_object);-
255 delete this;-
256}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickdesignersupport
4
257-
258-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0