Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qqmlguardedcontextdata_p.h
Go to the documentation of this file.
1
// Copyright (C) 2020 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
4
5
#
ifndef
QQMLGUARDEDCONTEXTDATA_P_H
6
#
define
QQMLGUARDEDCONTEXTDATA_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
<
QtQml
/
private
/
qtqmlglobal_p
.
h
>
20
#
include
<
QtQml
/
private
/
qqmlcontextdata_p
.
h
>
21
22
QT_BEGIN_NAMESPACE
23
24
class
QQmlGuardedContextData
25
{
26
Q_DISABLE_COPY(QQmlGuardedContextData);
27
public
:
28
QQmlGuardedContextData() =
default
;
29
~QQmlGuardedContextData() { unlink(); }
30
31
QQmlGuardedContextData(QQmlGuardedContextData &&) =
default
;
32
QQmlGuardedContextData &operator=(QQmlGuardedContextData &&) =
default
;
33
34
QQmlGuardedContextData(QQmlRefPointer<QQmlContextData> data)
35
{
36
setContextData(std::move(data));
37
}
38
39
QQmlGuardedContextData &operator=(QQmlRefPointer<QQmlContextData> d)
40
{
41
setContextData(std::move(d));
42
return
*
this
;
43
}
44
45
QQmlRefPointer<QQmlContextData> contextData()
const
{
return
m_contextData; }
46
void
setContextData(QQmlRefPointer<QQmlContextData> contextData)
47
{
48
if
(m_contextData.data() == contextData.data())
49
return
;
50
unlink();
51
52
if
(contextData) {
53
m_contextData = std::move(contextData);
54
m_next = m_contextData->m_contextGuards;
55
if
(m_next)
56
m_next->m_prev = &m_next;
57
58
m_contextData->m_contextGuards =
this
;
59
m_prev = &m_contextData->m_contextGuards;
60
}
61
}
62
63
bool
isNull()
const
{
return
!m_contextData; }
64
65
operator
const
QQmlRefPointer<QQmlContextData> &()
const
{
return
m_contextData; }
66
QQmlContextData &operator*()
const
{
return
m_contextData.operator*(); }
67
QQmlContextData *operator->()
const
{
return
m_contextData.operator->(); }
68
69
QQmlGuardedContextData *next()
const
{
return
m_next; }
70
71
private
:
72
void
reset()
73
{
74
m_contextData.reset();
75
m_next =
nullptr
;
76
m_prev =
nullptr
;
77
}
78
79
void
unlink()
80
{
81
if
(m_prev) {
82
*m_prev = m_next;
83
if
(m_next)
84
m_next->m_prev = m_prev;
85
reset();
86
}
87
}
88
89
QQmlRefPointer<QQmlContextData> m_contextData;
90
QQmlGuardedContextData *m_next =
nullptr
;
91
QQmlGuardedContextData **m_prev =
nullptr
;
92
};
93
94
QT_END_NAMESPACE
95
96
#
endif
// QQMLGUARDEDCONTEXTDATA_P_H
qtdeclarative
src
qml
qml
qqmlguardedcontextdata_p.h
Generated on
for Qt by
1.18.0