Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlvme_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLVME_P_H
5#define QQMLVME_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qrecursionwatcher_p.h>
19
20#include <QtCore/QStack>
21#include <QtCore/QString>
22#include <QtCore/qelapsedtimer.h>
23#include <QtCore/qdeadlinetimer.h>
24#include <QtCore/qcoreapplication.h>
25#include <QtCore/qtypeinfo.h>
26
27#include <private/qqmlengine_p.h>
28
29#include <atomic>
30
31QT_BEGIN_NAMESPACE
32
33class QObject;
34
36public:
38 inline QQmlInstantiationInterrupt(std::atomic<bool> *runWhile,
39 QDeadlineTimer deadline = QDeadlineTimer::Forever);
40 inline QQmlInstantiationInterrupt(QDeadlineTimer deadline);
41
42 inline bool shouldInterrupt() const;
43private:
44 enum Mode { None, Time, Flag };
45 Mode mode;
46 QDeadlineTimer deadline;
47 std::atomic<bool> *runWhile = nullptr;
48};
49
50class Q_QML_EXPORT QQmlVME
51{
52public:
53 static void enableComponentComplete();
54 static void disableComponentComplete();
55 static bool componentCompleteEnabled();
56
57private:
58 static bool s_enableComponentComplete;
59};
60
61// Used to check that a QQmlVME that is interrupted mid-execution
62// is still valid. Checks all the objects and contexts have not been
63// deleted.
64//
65// VME stands for Virtual Machine Execution. QML files used to
66// be compiled to a byte code data structure that a virtual machine executed
67// (for constructing the tree of QObjects and setting properties).
69{
70public:
72 ~QQmlVMEGuard();
73
74 void guard(QQmlObjectCreator *);
75 void clear();
76
77 bool isOK() const;
78
79private:
80 size_t m_objectCount;
81 QQmlGuard<QObject> *m_objects;
82 int m_contextCount;
83 QQmlGuardedContextData *m_contexts;
84};
85
90
91QQmlInstantiationInterrupt::QQmlInstantiationInterrupt(std::atomic<bool> *runWhile, QDeadlineTimer deadline)
92 : mode(Flag), deadline(deadline), runWhile(runWhile)
93{
94}
95
97 : mode(Time), deadline(deadline)
98{
99}
100
102{
103 switch (mode) {
104 case None:
105 return false;
106 case Time:
107 return deadline.hasExpired();
108 case Flag:
109 return !runWhile->load(std::memory_order_acquire) || deadline.hasExpired();
110 }
111 Q_UNREACHABLE_RETURN(false);
112}
113
114QT_END_NAMESPACE
115
116#endif // QQMLVME_P_H
\inmodule QtCore
Definition qobject.h:105
void setInitialState(QObject *o) override
Called after the object is first created, but before complex property bindings are evaluated and,...
void statusChanged(Status s) override
Called when the status of the incubator changes.
QQmlComponentIncubator(QV4::Heap::QmlIncubatorObject *inc, IncubationMode mode)
QV4::PersistentValue incubatorObject
The QQmlComponent class encapsulates a QML component definition.
The QQmlError class encapsulates a QML error.
Definition qqmlerror.h:18
Status
Specifies the status of the QQmlIncubator.
QQmlInstantiationInterrupt(std::atomic< bool > *runWhile, QDeadlineTimer deadline=QDeadlineTimer::Forever)
Definition qqmlvme_p.h:91
bool shouldInterrupt() const
Definition qqmlvme_p.h:101
QQmlInstantiationInterrupt(QDeadlineTimer deadline)
Definition qqmlvme_p.h:96
bool isOK() const
Definition qqmlvme.cpp:76
void guard(QQmlObjectCreator *)
Definition qqmlvme.cpp:50
void clear()
Definition qqmlvme.cpp:65
DECLARE_HEAP_OBJECT(QmlContext, ExecutionContext)
Definition qjsvalue.h:23
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
Q_DECLARE_TYPEINFO(QByteArrayView, Q_PRIMITIVE_TYPE)
static void removePendingQPropertyBinding(QV4::Value *object, const QString &propertyName, const QQmlObjectCreator *creator)
static void QQmlComponent_setQmlParent(QObject *me, QObject *parent)
DEFINE_OBJECT_VTABLE(QV4::QmlIncubatorObject)
V4_DEFINE_EXTENSION(QQmlComponentExtension, componentExtension)
static QQmlParserStatus * parserStatusCast(const QQmlType &type, QObject *rv)
QDebug Q_QML_EXPORT operator<<(QDebug debug, const QQmlError &error)
static ReturnedValue method_set_statusChanged(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_get_status(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_get_object(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void statusChanged(QQmlIncubator::Status)
void setInitialState(QObject *, RequiredProperties *requiredProperties)
static ReturnedValue method_forceCompletion(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)