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
qquickdeferredpointer_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKDEFERREDPOINTER_P_P_H
6#define QQUICKDEFERREDPOINTER_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qglobal.h>
20#include <QtQml/private/qbipointer_p.h>
21#include <QtQml/private/qqmlcomponent_p.h>
22
24
26{
28public:
30 {
31 return value.isT1() ? nullptr : &value.asT2()->state;
32 }
33
35 {
36 if (value.isT1())
37 return;
40 value = state->value;
41 delete state;
42 }
43
44 bool wasExecuted() const { return value.isT1() && value.flag(); }
46 {
48 value.setFlag();
49 }
50
51 bool isExecuting() const { return value.isT2() && value.flag(); }
52 bool setExecuting(bool b)
53 {
54 if (b) {
55 if (value.isT2()) {
56 // Not our state. Set the flag, but leave it alone.
57 value.setFlag();
58 return false;
59 }
60
61 value = new DeferredState {
63 value.asT1()
64 };
65 value.setFlag();
66 return true;
67 }
68
69 if (value.isT2()) {
71 return true;
72 }
73
74 return false;
75 }
76
77protected:
80 {
81 Q_ASSERT(value.isT1());
82 Q_ASSERT(!value.flag());
83 }
84
86 {
87 if (value.isT1())
88 value = v;
89 else
90 value.asT2()->value = v;
91 return *this;
92 }
93
95 {
96 if (value.isT2())
97 delete value.asT2();
98 }
99
100 void *data() const { return value.isT1() ? value.asT1() : value.asT2()->value; }
101
102private:
103 struct DeferredState
104 {
105 QQmlComponentPrivate::DeferredState state;
106 void *value = nullptr;
107 };
108
109 QBiPointer<void, DeferredState> value;
110};
111
112template<typename T>
114{
116public:
119
122 QQuickUntypedDeferredPointer::operator=(o);
123 return *this;
124 }
125
126 T *data() const { return static_cast<T *>(QQuickUntypedDeferredPointer::data()); }
127 operator bool() const { return data() != nullptr; }
128 operator T*() const { return data(); }
129 T *operator*() const { return data(); }
130 T *operator->() const { return data(); }
131};
132
133QT_END_NAMESPACE
134
135#endif // QQUICKDEFERREDPOINTER_P_P_H
~QQuickDeferredPointer()=default
QQuickDeferredPointer< T > & operator=(T *o)
Container for context-sensitive controls.
QQuickUntypedDeferredPointer & operator=(void *v)
bool isInteractiveControlType(const QQuickItem *item)
static void layoutItem(QQuickItem *item, qreal y, qreal width)
static const QQuickItemPrivate::ChangeTypes ItemChanges
Styled top-level window with support for a header and footer.
static QQuickItem * findActiveFocusControl(QQuickWindow *window)