From 5cdeb08485f3ed49efc3d0b918254e78ad00c84b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 12 Feb 2010 14:57:09 +1000 Subject: Reference count shared expression data QmlExpression uses data from the QmlCompiledComponent (eg. expression string data). It must therefore hold a reference to the QmlCompiledComponent to prevent the data being deleted. --- src/declarative/qml/qmlexpression.cpp | 7 ++++++- src/declarative/qml/qmlexpression_p.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index ff1705b..6f32ef4 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -71,7 +71,7 @@ bool QmlDelayedError::addError(QmlEnginePrivate *e) } QmlExpressionData::QmlExpressionData() -: expressionFunctionValid(false), expressionRewritten(false), me(0), +: q(0), dataRef(0), expressionFunctionValid(false), expressionRewritten(false), me(0), trackChange(true), isShared(false), line(-1), guardList(0), guardListLength(0) { } @@ -79,6 +79,7 @@ QmlExpressionData::QmlExpressionData() QmlExpressionData::~QmlExpressionData() { if (guardList) { delete [] guardList; guardList = 0; } + if (dataRef) dataRef->release(); } QmlExpressionPrivate::QmlExpressionPrivate() @@ -113,6 +114,10 @@ void QmlExpressionPrivate::init(QmlContext *ctxt, void *expr, QmlRefCount *rc, data->url = url; data->line = lineNumber; + if (data->dataRef) data->dataRef->release(); + data->dataRef = rc; + if (data->dataRef) data->dataRef->addref(); + quint32 *exprData = (quint32 *)expr; QmlCompiledData *dd = (QmlCompiledData *)rc; diff --git a/src/declarative/qml/qmlexpression_p.h b/src/declarative/qml/qmlexpression_p.h index 1fbb075..b19c60c 100644 --- a/src/declarative/qml/qmlexpression_p.h +++ b/src/declarative/qml/qmlexpression_p.h @@ -114,6 +114,7 @@ public: QmlExpressionPrivate *q; + QmlRefCount *dataRef; QString expression; bool expressionFunctionValid:1; bool expressionRewritten:1; -- cgit v0.12