Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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#include <private/qfinitestack_p.h>
29
30#include <atomic>
31
33
34class QObject;
35
37public:
39 inline QQmlInstantiationInterrupt(std::atomic<bool> *runWhile,
42
43 inline bool shouldInterrupt() const;
44private:
45 enum Mode { None, Time, Flag };
46 Mode mode;
48 std::atomic<bool> *runWhile = nullptr;
49};
50
51class Q_QML_EXPORT QQmlVME
52{
53public:
54 static void enableComponentComplete();
55 static void disableComponentComplete();
56 static bool componentCompleteEnabled();
57
58private:
59 static bool s_enableComponentComplete;
60};
61
62// Used to check that a QQmlVME that is interrupted mid-execution
63// is still valid. Checks all the objects and contexts have not been
64// deleted.
65//
66// VME stands for Virtual Machine Execution. QML files used to
67// be compiled to a byte code data structure that a virtual machine executed
68// (for constructing the tree of QObjects and setting properties).
70{
71public:
74
76 void clear();
77
78 bool isOK() const;
79
80private:
81 int m_objectCount;
82 QQmlGuard<QObject> *m_objects;
83 int m_contextCount;
84 QQmlGuardedContextData *m_contexts;
85};
86
91
93 : mode(Flag), deadline(deadline), runWhile(runWhile)
94{
95}
96
101
103{
104 switch (mode) {
105 case None:
106 return false;
107 case Time:
108 return deadline.hasExpired();
109 case Flag:
110 return !runWhile->load(std::memory_order_acquire) || deadline.hasExpired();
111 }
112 Q_UNREACHABLE_RETURN(false);
113}
114
116
117#endif // QQMLVME_P_H
\inmodule QtCore
bool hasExpired() const noexcept
Returns true if this QDeadlineTimer object has expired, false if there remains time left.
static constexpr ForeverConstant Forever
\inmodule QtCore
Definition qobject.h:103
bool shouldInterrupt() const
Definition qqmlvme_p.h:102
bool isOK() const
Definition qqmlvme.cpp:77
void guard(QQmlObjectCreator *)
Definition qqmlvme.cpp:51
void clear()
Definition qqmlvme.cpp:66
Combined button and popup list for selecting options.
@ None
Definition qhash.cpp:531
GLenum mode
QDeadlineTimer deadline(30s)