コード例 #1
0
QDeclarativePropertyCache::Data *QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj, 
                                                   const QString &name, Data &local)
{
    QDeclarativePropertyCache::Data *rv = 0;

    if (!engine) {
        local = QDeclarativePropertyCache::create(obj->metaObject(), name);
        if (local.isValid())
            rv = &local;
    } else {
        QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine);

        QDeclarativePropertyCache *cache = 0;
        QDeclarativeData *ddata = QDeclarativeData::get(obj);
        if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine)
            cache = ddata->propertyCache;
        if (!cache) {
            cache = enginePrivate->cache(obj);
            if (cache && ddata && !ddata->propertyCache) { cache->addref(); ddata->propertyCache = cache; }
        }

        if (cache) {
            rv = cache->property(name);
        } else {
            local = QDeclarativePropertyCache::create(obj->metaObject(), name);
            if (local.isValid())
                rv = &local;
        }
    }

    return rv;
}
コード例 #2
0
QDeclarativePropertyCache::Data *
QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj, 
                                    const QHashedV8String &name, Data &local)
{
    // XXX Optimize for worker script case where engine isn't available
    QDeclarativePropertyCache *cache = 0;
    if (engine) {
        QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);

        QDeclarativeData *ddata = QDeclarativeData::get(obj);
        if (ddata && ddata->propertyCache)
            cache = ddata->propertyCache;
        if (!cache) {
            cache = ep->cache(obj);
            if (cache && ddata && !ddata->propertyCache) { cache->addref(); ddata->propertyCache = cache; }
        }
    }

    QDeclarativePropertyCache::Data *rv = 0;

    if (cache) {
        rv = cache->property(name);
    } else {
        QString strname = QV8Engine::toStringStatic(name.string());
        // QString strname = ep->v8engine()->toString(name);
        local = QDeclarativePropertyCache::create(obj->metaObject(), strname);
        if (local.isValid())
            rv = &local;
    }

    return rv;
}