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
qqmlpreviewbindingpatchcontext_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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#ifndef QQMLPREVIEWBINDINGPATCHCONTEXT_P_H
5#define QQMLPREVIEWBINDINGPATCHCONTEXT_P_H
6
7#include <private/qduplicatetracker_p.h>
8#include <private/qqmlanybinding_p.h>
9#include <private/qqmlboundsignal_p.h>
10#include <private/qqmlcontextdata_p.h>
11#include <private/qqmldata_p.h>
12#include <private/qqmlvmemetaobject_p.h>
13#include <private/qv4executablecompilationunit_p.h>
14
15#include <QtCore/qpointer.h>
16
17#include <unordered_map>
18
19//
20// W A R N I N G
21// -------------
22//
23// This file is not part of the Qt API. It exists purely as an
24// implementation detail. This header file may change from version to
25// version without notice, or even be removed.
26//
27// We mean it.
28//
29
30QT_BEGIN_NAMESPACE
31
32namespace QQmlPreview {
33
43
44// Maps a property name bound by the new compilation unit to the new binding. Used to
45// recognize properties that repopulateBindings() will re-assign (so resetting them is
46// redundant) and, for group/attached properties, to find the matching new sub-object.
48
50{
51public:
52 BindingPatchContext(QObject *object, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit,
53 int objectIndex, const QString &prefix)
54 : m_object(object), unit(unit), objectIndex(objectIndex), prefix(prefix + QLatin1Char('.'))
55 {
56 }
57
58 BindingPatchContext(QObject *object, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit,
59 int objectIndex)
60 : m_object(object), unit(unit), objectIndex(objectIndex)
61 {
62 }
63
64 void reset(const std::vector<QQmlRefPointer<QV4::ExecutableCompilationUnit>> &unitsToUnparent,
65 const std::vector<CompositeLevel> &internalUnits);
67 const std::vector<CompositeLevel> &internalUnits,
68 QDuplicateTracker<QObject *> *seenChildren);
69 void refreshObjects();
71
72 BindingPatchContext *childContext(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit,
73 const QV4::CompiledData::Binding *binding,
74 QDuplicateTracker<QObject *> *seenChildren);
75 BindingPatchContext *childContext(const QString &name, QObject *object,
76 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit,
77 int objectIndex, QDuplicateTracker<QObject *> *seenChildren);
78 BindingPatchContext *attachedContext(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit,
79 const QV4::CompiledData::Binding *binding,
80 QDuplicateTracker<QObject *> *seenChildren);
81
82private:
83 struct StoredBinding
84 {
85 QString propertyName;
86 QQmlAnyBinding binding;
87 QPointer<QObject> sourceGuard;
88 };
89
90 struct StoredValue
91 {
92 QString propertyName;
93 QVariant value;
94 };
95
96 struct StoredSignalHandler
97 {
98 QString signature;
99 std::unique_ptr<QQmlBoundSignal> handler;
100 };
101
102 void recordBindingValues(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit,
103 int cuIndex, QHash<QString, QVariant> *constantValues,
104 QDuplicateTracker<QObject *> *seenChildren);
105 void resetBinding(const QV4::CompiledData::Binding *binding, const QString &name,
106 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &oldUnit,
107 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &newUnit,
108 const ReboundBindings &rebound);
109 void resetBindings(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit, int cuIndex,
110 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &newUnit,
111 int newCuIndex);
112 static void retireObject(QObject *object);
113 static void clearBindingsRecursive(QObject *object);
114
115 QPointer<QObject> m_object;
116 QQmlRefPointer<QV4::ExecutableCompilationUnit> unit;
117 int objectIndex;
118 QString prefix;
119
120 std::vector<StoredBinding> m_storedBindings;
121 std::vector<StoredValue> m_storedValues;
122 std::vector<StoredSignalHandler> m_storedSignalHandlers;
124};
125
126} // namespace QQmlPreview
127
128QT_END_NAMESPACE
129
130#endif
void reset(const std::vector< QQmlRefPointer< QV4::ExecutableCompilationUnit > > &unitsToUnparent, const std::vector< CompositeLevel > &internalUnits)
BindingPatchContext * attachedContext(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &unit, const QV4::CompiledData::Binding *binding, QDuplicateTracker< QObject * > *seenChildren)
BindingPatchContext * childContext(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &unit, const QV4::CompiledData::Binding *binding, QDuplicateTracker< QObject * > *seenChildren)
BindingPatchContext * childContext(const QString &name, QObject *object, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &unit, int objectIndex, QDuplicateTracker< QObject * > *seenChildren)
BindingPatchContext(QObject *object, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &unit, int objectIndex)
BindingPatchContext(QObject *object, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &unit, int objectIndex, const QString &prefix)
void stashExternalState(const std::vector< CompositeLevel > &internalUnits, QDuplicateTracker< QObject * > *seenChildren)
static ReboundBindings reboundBindings(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &unit, int cuIndex)
static bool functionBelongsToObject(const QV4::Function *f, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &cu, int objectIndex)
static QObject * propertyToPropertySource(const QQmlAnyBinding &binding)
static int reboundSubObjectIndex(const ReboundBindings &rebound, const QString &name, QV4::CompiledData::Binding::Type type)
static bool isExternalBinding(const QQmlAnyBinding &binding, const std::vector< CompositeLevel > &internalUnits, QObject *target)
Combined button and popup list for selecting options.
QQmlRefPointer< QV4::ExecutableCompilationUnit > newCu
QQmlRefPointer< QV4::ExecutableCompilationUnit > oldCu
QQmlRefPointer< QQmlContextData > context