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
qqmlnotifier.cpp
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// Qt-Security score:significant
4
6#include <private/qqmldata_p.h>
7#include <QtCore/qdebug.h>
8
10
11typedef void (*Callback)(QQmlNotifierEndpoint *, void **);
12
13void QQmlBoundSignal_callback(QQmlNotifierEndpoint *, void **);
14void QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint *, void **);
15void QQmlVMEMetaObjectEndpoint_callback(QQmlNotifierEndpoint *, void **);
16void QQmlUnbindableToUnbindableGuard_callback(QQmlNotifierEndpoint *, void **);
17void QQmlUnbindableToBindableGuard_callback(QQmlNotifierEndpoint *, void **);
18void QQmlDirtyReferenceObject_callback(QQmlNotifierEndpoint *, void **);
19
21 nullptr,
22 QQmlBoundSignal_callback,
23 QQmlJavaScriptExpressionGuard_callback,
24 QQmlVMEMetaObjectEndpoint_callback,
25 QQmlUnbindableToUnbindableGuard_callback,
26 QQmlUnbindableToBindableGuard_callback,
27 QQmlDirtyReferenceObject_callback,
28};
29
30namespace {
31 struct NotifyListTraversalData {
32 NotifyListTraversalData(QQmlNotifierEndpoint *ep = nullptr)
33 : originalSenderPtr(0)
34 , disconnectWatch(nullptr)
35 , endpoint(ep)
36 {}
37
38 qintptr originalSenderPtr;
39 qintptr *disconnectWatch;
40 QQmlNotifierEndpoint *endpoint;
41 };
42}
43
44void QQmlNotifier::notify(QQmlData *ddata, int notifierIndex)
45{
46 if (QQmlNotifierEndpoint *ep = ddata->notify(notifierIndex))
47 emitNotify(ep, nullptr);
48}
49
50void QQmlNotifier::emitNotify(QQmlNotifierEndpoint *endpoint, void **a)
51{
52 QVarLengthArray<NotifyListTraversalData> stack;
53 while (endpoint) {
54 stack.append(NotifyListTraversalData(endpoint));
55 endpoint = endpoint->next;
56 }
57
58 int i = 0;
59 for (; i < stack.size(); ++i) {
60 NotifyListTraversalData &data = stack[i];
61
62 if (!data.endpoint->isNotifying()) {
63 data.endpoint->startNotifying(&data.originalSenderPtr);
64 data.disconnectWatch = &data.originalSenderPtr;
65 } else {
66 data.disconnectWatch = (qintptr *)(data.endpoint->senderPtr & ~0x1);
67 }
68 }
69
70 while (--i >= 0) {
71 NotifyListTraversalData &data = stack[i];
72 if (*data.disconnectWatch) {
73 Q_ASSERT(QQmlNotifier_callbacks[data.endpoint->callback]);
74 QQmlNotifier_callbacks[data.endpoint->callback](data.endpoint, a);
75 if (data.disconnectWatch == &data.originalSenderPtr && data.originalSenderPtr) {
76 data.endpoint->stopNotifying(&data.originalSenderPtr);
77 }
78 }
79 }
80}
81
82/*! \internal
83 \a sourceSignal MUST be in the signal index range (see QObjectPrivate::signalIndex()).
84 This is different from QMetaMethod::methodIndex().
85*/
86
87
88QT_END_NAMESPACE
Combined button and popup list for selecting options.
void QQmlBoundSignal_callback(QQmlNotifierEndpoint *e, void **a)
void QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint *e, void **)
void QQmlUnbindableToUnbindableGuard_callback(QQmlNotifierEndpoint *, void **)
void QQmlVMEMetaObjectEndpoint_callback(QQmlNotifierEndpoint *, void **)
void QQmlUnbindableToBindableGuard_callback(QQmlNotifierEndpoint *, void **)
QT_BEGIN_NAMESPACE typedef void(* Callback)(QQmlNotifierEndpoint *, void **)
static Callback QQmlNotifier_callbacks[]
void QQmlDirtyReferenceObject_callback(QQmlNotifierEndpoint *e, void **)