MCPcopy Create free account
hub / github.com/KDAB/GammaRay / objectAdded

Method objectAdded

core/metaobjectregistry.cpp:163–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163void MetaObjectRegistry::objectAdded(QObject *obj)
164{
165 // Probe::objectFullyConstructed calls us and ensures this already
166 Q_ASSERT(thread() == QThread::currentThread());
167 Q_ASSERT(Probe::instance()->isValidObject(obj));
168
169 Q_ASSERT(!obj->parent() || Probe::instance()->isValidObject(obj->parent()));
170
171 const QMetaObject *metaObject = obj->metaObject();
172 metaObject = addMetaObject(metaObject, hasDynamicMetaObject(obj));
173
174 /*
175 * This will increase these values:
176 * - selfCount for that particular @p metaObject
177 * - inclusiveCount for @p metaObject and *all* ancestors
178 *
179 * Complexity-wise the inclusive count calculation should be okay,
180 * since the number of ancestors should be rather small
181 * (QMetaObject class hierarchy is rather a broad than a deep tree structure)
182 *
183 * If this yields some performance issues, we might need to remove the inclusive
184 * costs calculation altogether (a calculate-on-request pattern should be even slower)
185 */
186 m_metaObjectMap.insert(obj, metaObject);
187 auto &info = m_metaObjectInfoMap[metaObject];
188 ++info.selfCount;
189 ++info.selfAliveCount;
190 if (info.isDynamic)
191 addAliveInstance(obj, metaObject);
192
193 // increase inclusive counts
194 const QMetaObject *current = metaObject;
195 while (current) {
196 auto &info = m_metaObjectInfoMap[current];
197 ++info.inclusiveCount;
198 ++info.inclusiveAliveCount;
199 info.invalid = false;
200 emit dataChanged(current);
201 current = parentOf(current);
202 }
203}
204
205// Lifted from Qt
206struct MetaTypeCoreHelper final : public QMetaTypeModuleHelper

Callers

nothing calls this directly

Calls 4

hasDynamicMetaObjectFunction · 0.85
parentMethod · 0.45
metaObjectMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected