diff options
Diffstat (limited to 'src/declarative/qml/qdeclarativecomponent.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativecomponent.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 8238252db2..aa1bbd156f 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -836,6 +836,34 @@ QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context, cons return begin(context, creationContext, cc, start, count, &state, 0, bindings); } +/* + Try to do what's necessary for a reasonable display of the type + name, but no more (just enough for the client to do more extensive cleanup). + + Should only be called when debugging is enabled. +*/ +static inline QString buildTypeNameForDebug(const QMetaObject *metaObject) +{ + static const QString qmlMarker(QLatin1String("_QML")); + static const QChar underscore(QLatin1Char('_')); + static const QChar asterisk(QLatin1Char('*')); + QDeclarativeType *type = QDeclarativeMetaType::qmlType(metaObject); + QString typeName = type ? QLatin1String(type->qmlTypeName()) : QLatin1String(metaObject->className()); + if (!type) { + //### optimize further? + int marker = typeName.indexOf(qmlMarker); + if (marker != -1 && marker < typeName.count() - 1) { + if (typeName[marker + 1] == underscore) { + const QString className = typeName.left(marker) + asterisk; + type = QDeclarativeMetaType::qmlType(QMetaType::type(className.toLatin1())); + if (type) + typeName = QLatin1String(type->qmlTypeName()); + } + } + } + return typeName; +} + QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentContext, QDeclarativeContextData *componentCreationContext, QDeclarativeCompiledData *component, int start, int count, @@ -848,10 +876,8 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentCon Q_ASSERT(!isRoot || state); // Either this isn't a root component, or a state data must be provided Q_ASSERT((state != 0) ^ (errors != 0)); // One of state or errors (but not both) must be provided - if (isRoot) { + if (isRoot) QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Creating); - QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Creating, component->url); - } QDeclarativeContextData *ctxt = new QDeclarativeContextData; ctxt->isInternal = true; @@ -868,7 +894,9 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentCon enginePriv->inBeginCreate = true; QDeclarativeVME vme; + enginePriv->referenceScarceResources(); // "hold" scarce resources in memory during evaluation. QObject *rv = vme.run(ctxt, component, start, count, bindings); + enginePriv->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. if (vme.isError()) { if(errors) *errors = vme.errors(); @@ -897,6 +925,11 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentCon if (!parentContext->isInternal) parentContext->asQDeclarativeContextPrivate()->instances.append(rv); QDeclarativeEngineDebugServer::instance()->objectCreated(parentContext->engine, rv); + if (isRoot) { + QDeclarativeDebugTrace::rangeData(QDeclarativeDebugTrace::Creating, buildTypeNameForDebug(rv->metaObject())); + QDeclarativeData *data = QDeclarativeData::get(rv); + QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::Creating, component->url, data ? data->lineNumber : -1); + } } return rv; |