6#include <QtQml/qqmlengine.h>
7#include <QtQml/private/qqmlcomponentattached_p.h>
8#include <QtQml/private/qqmljavascriptexpression_p.h>
9#include <QtQml/private/qqmlguardedcontextdata_p.h>
39 if (
src.isRelative() && !
src.isEmpty()) {
45 const QUrl ctxtUrl = ctxt->
url();
52 if (m_engine && resolved.
isEmpty())
68 if (!m_hasEmittedDestruction) {
69 m_hasEmittedDestruction =
true;
74 while (m_componentAttacheds) {
81 child->emitDestruction();
90 while (m_childContexts) {
96 *m_prevChild = m_nextChild;
97 if (m_nextChild) m_nextChild->m_prevChild = m_prevChild;
98 m_nextChild =
nullptr;
99 m_prevChild =
nullptr;
102 m_importedScripts.
clear();
112 for (
auto ctxIt = m_childContexts; ctxIt; ctxIt = ctxIt->m_nextChild)
113 ctxIt->clearContextRecursively();
124 expression->m_prevExpression =
nullptr;
125 expression->m_nextExpression =
nullptr;
129 expression = nextExpression;
131 m_expressions =
nullptr;
134QQmlContextData::~QQmlContextData()
142 m_linkedContext.
reset();
148 while (m_ownedObjects) {
161 while (contextGuard) {
164 contextGuard->setContextData({});
167 m_contextGuards =
nullptr;
170 delete [] m_idValues;
171 m_idValues =
nullptr;
175 delete m_publicContext;
184 if (expression->m_nextExpression)
185 refreshExpressionsRecursive(expression->m_nextExpression);
191void QQmlContextData::refreshExpressionsRecursive(
bool isGlobal)
194 if (hasExpressionsToRun(isGlobal) && (m_nextChild || m_childContexts)) {
198 m_childContexts->refreshExpressionsRecursive(isGlobal);
200 if (guard.isNull())
return;
203 m_nextChild->refreshExpressionsRecursive(isGlobal);
205 if (guard.isNull())
return;
207 if (hasExpressionsToRun(isGlobal))
208 refreshExpressionsRecursive(m_expressions);
210 }
else if (hasExpressionsToRun(isGlobal)) {
211 refreshExpressionsRecursive(m_expressions);
212 }
else if (m_nextChild && m_childContexts) {
214 m_childContexts->refreshExpressionsRecursive(isGlobal);
215 if (!guard.isNull() && m_nextChild)
216 m_nextChild->refreshExpressionsRecursive(isGlobal);
217 }
else if (m_nextChild) {
218 m_nextChild->refreshExpressionsRecursive(isGlobal);
219 }
else if (m_childContexts) {
220 m_childContexts->refreshExpressionsRecursive(isGlobal);
229 bool isGlobal = (m_parent ==
nullptr);
232 if (hasExpressionsToRun(isGlobal) && m_childContexts) {
234 m_childContexts->refreshExpressionsRecursive(isGlobal);
235 if (!guard.
isNull() && hasExpressionsToRun(isGlobal))
236 refreshExpressionsRecursive(m_expressions);
237 }
else if (hasExpressionsToRun(isGlobal)) {
238 refreshExpressionsRecursive(m_expressions);
239 }
else if (m_childContexts) {
240 m_childContexts->refreshExpressionsRecursive(isGlobal);
246 if (
data->outerContext) {
247 if (
data->nextContextObject)
248 data->nextContextObject->prevContextObject =
data->prevContextObject;
249 if (
data->prevContextObject)
250 *
data->prevContextObject =
data->nextContextObject;
251 else if (
data->outerContext->m_ownedObjects ==
data)
252 data->outerContext->m_ownedObjects =
data->nextContextObject;
255 data->outerContext =
this;
257 data->nextContextObject = m_ownedObjects;
258 if (
data->nextContextObject)
261 m_ownedObjects =
data;
266 m_idValues[idx] =
obj;
267 m_idValues[idx].setContext(
this);
272 for (
int ii = 0; ii < m_idValueCount; ii++) {
273 if (m_idValues[ii] ==
obj)
278 if (m_publicContext) {
280 for (
int ii = 0; ii <
p->numPropertyValues(); ++ii)
281 if (
p->propertyValue(ii) == objVariant)
285 if (m_contextObject) {
293 && prop.
read(m_contextObject) == objVariant) {
305 m_typeCompilationUnit = unit;
306 m_componentObjectIndex = subComponentIndex == -1 ? 0 : subComponentIndex;
308 m_idValueCount = m_typeCompilationUnit->
objectAt(m_componentObjectIndex)
310 m_idValues =
new ContextGuard[m_idValueCount];
323void QQmlContextData::initPropertyNames()
const
325 if (m_typeCompilationUnit)
334 if (m_typeCompilationUnit)
335 return m_typeCompilationUnit->
finalUrl();
341 if (m_typeCompilationUnit)
343 return m_baseUrlString;
QV4::ExecutionEngine * handle() const
void insertIntoList(QQmlComponentAttached **listHead)
QString findObjectId(const QObject *obj) const
QUrl resolvedUrl(const QUrl &) const
void installContext(QQmlData *ddata, QmlObjectKind kind)
void initFromTypeCompilationUnit(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &unit, int subComponentIndex)
void addExpression(QQmlJavaScriptExpression *expression)
void setLinkedContext(const QQmlRefPointer< QQmlContextData > &context)
void addComponentAttached(QQmlComponentAttached *attached)
void addOwnedObject(QQmlData *ownedObject)
void refreshExpressions()
void setIdValue(int index, QObject *idValue)
void clearContextRecursively()
QString urlString() const
QQmlRefPointer< QQmlContextData > parent() const
QString propertyName(int index) const
static QQmlContextPrivate * get(QQmlContext *context)
QQmlRefPointer< QQmlContextData > ownContext
QQmlContextData * context
QQmlData ** prevContextObject
QQmlData * nextContextObject
QQmlContextData * outerContext
QUrl baseUrl() const
Return the base URL for this engine.
QUrl interceptUrl(const QUrl &url, QQmlAbstractUrlInterceptor::DataType type) const
Run the current URL interceptors on the given url of the given type and return the result.
void insertIntoList(QQmlJavaScriptExpression **listHead)
void setContext(const QQmlRefPointer< QQmlContextData > &context)
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString url(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
const CompiledObject * objectAt(int index) const
IdentifierHash namedObjectsPerComponent(int componentObjectIndex)
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Combined button and popup list for selecting options.
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
obj metaObject() -> className()
QString finalUrlString() const
quint32_le nNamedObjectsInComponent