Example #1
0
void QDeclarativeContextData::clearContext()
{
    if (engine) {
        while (componentAttached) {
            QDeclarativeComponentAttached *a = componentAttached;
            componentAttached = a->next;
            if (componentAttached) componentAttached->prev = &componentAttached;

            a->next = 0;
            a->prev = 0;

            emit a->destruction();
        }
    }

    QDeclarativeAbstractExpression *expression = expressions;
    while (expression) {
        QDeclarativeAbstractExpression *nextExpression = expression->m_nextExpression;

        expression->m_context = 0;
        expression->m_prevExpression = 0;
        expression->m_nextExpression = 0;

        expression = nextExpression;
    }
    expressions = 0;
}
Example #2
0
void QDeclarativeContextData::invalidate()
{
    while (childContexts)
        childContexts->invalidate();

    while (componentAttached) {
        QDeclarativeComponentAttached *a = componentAttached;
        componentAttached = a->next;
        if (componentAttached) componentAttached->prev = &componentAttached;

        a->next = 0;
        a->prev = 0;

        emit a->destruction();
    }

    if (prevChild) {
        *prevChild = nextChild;
        if (nextChild) nextChild->prevChild = prevChild;
        nextChild = 0;
        prevChild = 0;
    }

    engine = 0;
    parent = 0;
}
Example #3
0
void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state)
{
    if (state->completePending) {

        for (int ii = 0; ii < state->bindValues.count(); ++ii) {
            QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding> bv =
                state->bindValues.at(ii);
            for (int jj = 0; jj < bv.count; ++jj) {
                if(bv.at(jj))
                    bv.at(jj)->setEnabled(true, QDeclarativePropertyPrivate::BypassInterceptor |
                                          QDeclarativePropertyPrivate::DontRemoveBinding);
            }
            QDeclarativeEnginePrivate::clear(bv);
        }

        for (int ii = 0; ii < state->parserStatus.count(); ++ii) {
            QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus> ps =
                state->parserStatus.at(ii);

            for (int jj = ps.count - 1; jj >= 0; --jj) {
                QDeclarativeParserStatus *status = ps.at(jj);
                if (status && status->d) {
                    status->d = 0;
                    status->componentComplete();
                }
            }
            QDeclarativeEnginePrivate::clear(ps);
        }

        while (state->componentAttached) {
            QDeclarativeComponentAttached *a = state->componentAttached;
            a->rem();
            QDeclarativeData *d = QDeclarativeData::get(a->parent());
            Q_ASSERT(d);
            Q_ASSERT(d->context);
            a->add(&d->context->componentAttached);
            emit a->completed();
        }

        state->bindValues.clear();
        state->parserStatus.clear();
        state->completePending = false;

        enginePriv->inProgressCreations--;
        if (0 == enginePriv->inProgressCreations) {
            while (enginePriv->erroredBindings) {
                enginePriv->warning(enginePriv->erroredBindings->error);
                enginePriv->erroredBindings->removeError();
            }
        }
    }
}
Example #4
0
void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state)
{
    if (state->completePending) {

        for (int ii = 0; ii < state->bindValues.count(); ++ii) {
            QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding> bv = 
                state->bindValues.at(ii);
            for (int jj = 0; jj < bv.count; ++jj) {
                if(bv.at(jj)) 
                    bv.at(jj)->setEnabled(true, QDeclarativePropertyPrivate::BypassInterceptor | 
                                                QDeclarativePropertyPrivate::DontRemoveBinding);
            }
            QDeclarativeEnginePrivate::clear(bv);
        }

        for (int ii = 0; ii < state->parserStatus.count(); ++ii) {
            QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus> ps = 
                state->parserStatus.at(ii);

            for (int jj = ps.count - 1; jj >= 0; --jj) {
                QDeclarativeParserStatus *status = ps.at(jj);
                if (status && status->d) {
                    status->d = 0;
                    status->componentComplete();
                }
            }
            QDeclarativeEnginePrivate::clear(ps);
        }

        while (state->componentAttacheds) {
            QDeclarativeComponentAttached *a = state->componentAttacheds;
            if (a->next) a->next->prev = &state->componentAttacheds;
            state->componentAttacheds = a->next;
            a->prev = 0; a->next = 0;
            emit a->completed();
        }

        state->bindValues.clear();
        state->parserStatus.clear();
        state->completePending = false;

        enginePriv->inProgressCreations--;
        if (0 == enginePriv->inProgressCreations) {
            while (enginePriv->erroredBindings) {
                qWarning().nospace() << qPrintable(enginePriv->erroredBindings->error.toString());
                enginePriv->erroredBindings->removeError();
            }
        }
    }
}
Example #5
0
/*!
    \internal
*/
QDeclarativeComponentAttached *QDeclarativeComponent::qmlAttachedProperties(QObject *obj)
{
    QDeclarativeComponentAttached *a = new QDeclarativeComponentAttached(obj);

    QDeclarativeEngine *engine = qmlEngine(obj);
    if (!engine)
        return a;

    if (QDeclarativeEnginePrivate::get(engine)->inBeginCreate) {
        QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
        a->add(&p->componentAttached);
    } else {
        QDeclarativeData *d = QDeclarativeData::get(obj);
        Q_ASSERT(d);
        Q_ASSERT(d->context);
        a->add(&d->context->componentAttached);
    }

    return a;
}
Example #6
0
void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state)
{
    if (state->completePending) {
        QT_TRY {
            for (int ii = 0; ii < state->bindValues.count(); ++ii) {
                QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding> bv =
                    state->bindValues.at(ii);
                for (int jj = 0; jj < bv.count; ++jj) {
                    if(bv.at(jj)) {
                        // XXX akennedy
                        bv.at(jj)->m_mePtr = 0;
                        bv.at(jj)->setEnabled(true, QDeclarativePropertyPrivate::BypassInterceptor |
                                                    QDeclarativePropertyPrivate::DontRemoveBinding);
                    }
                }
                QDeclarativeEnginePrivate::clear(bv);
            }

            for (int ii = 0; ii < state->parserStatus.count(); ++ii) {
                QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus> ps =
                    state->parserStatus.at(ii);

                for (int jj = ps.count - 1; jj >= 0; --jj) {
                    QDeclarativeParserStatus *status = ps.at(jj);
                    if (status && status->d) {
                        status->d = 0;
                        status->componentComplete();
                    }
                }
                QDeclarativeEnginePrivate::clear(ps);
            }

            for (int ii = 0; ii < state->finalizedParserStatus.count(); ++ii) {
                QPair<QDeclarativeGuard<QObject>, int> status = state->finalizedParserStatus.at(ii);
                QObject *obj = status.first;
                if (obj) {
                    void *args[] = { 0 };
                    QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod,
                                          status.second, args);
                }
            }

            //componentComplete() can register additional finalization objects
            //that are then never handled. Handle them manually here.
            if (1 == enginePriv->inProgressCreations) {
                for (int ii = 0; ii < enginePriv->finalizedParserStatus.count(); ++ii) {
                    QPair<QDeclarativeGuard<QObject>, int> status = enginePriv->finalizedParserStatus.at(ii);
                    QObject *obj = status.first;
                    if (obj) {
                        void *args[] = { 0 };
                        QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod,
                                              status.second, args);
                    }
                }
                enginePriv->finalizedParserStatus.clear();
            }

            while (state->componentAttached) {
                QDeclarativeComponentAttached *a = state->componentAttached;
                a->rem();
                QDeclarativeData *d = QDeclarativeData::get(a->parent());
                Q_ASSERT(d);
                Q_ASSERT(d->context);
                a->add(&d->context->componentAttached);
                emit a->completed();
            }
        } QT_CATCH(const std::exception&) {
            state->bindValues.clear();
            state->parserStatus.clear();
            state->finalizedParserStatus.clear();
            state->completePending = false;
            enginePriv->inProgressCreations--;
            QT_RETHROW;
        }