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
qqmltypemodule.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 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#include "qqmltypemodule_p.h"
5
6#include <private/qqmltype_p_p.h>
7
8#include <QtCore/qmutex.h>
9
11
13{
14 for (int oldVersion = m_minMinorVersion.loadRelaxed();
15 oldVersion > version && !m_minMinorVersion.testAndSetOrdered(oldVersion, version);
16 oldVersion = m_minMinorVersion.loadRelaxed()) {
17 }
18
19 for (int oldVersion = m_maxMinorVersion.loadRelaxed();
20 oldVersion < version && !m_maxMinorVersion.testAndSetOrdered(oldVersion, version);
21 oldVersion = m_maxMinorVersion.loadRelaxed()) {
22 }
23}
24
26{
27 QMutexLocker lock(&m_mutex);
28
29 if (type->version.hasMinorVersion())
30 addMinorVersion(type->version.minorVersion());
31
32 QList<QQmlTypePrivate *> &list = m_typeHash[type->elementName];
33 for (int ii = 0; ii < list.size(); ++ii) {
34 QQmlTypePrivate *in_list = list.at(ii);
35 Q_ASSERT(in_list);
36 if (in_list->version.minorVersion() < type->version.minorVersion()) {
37 list.insert(ii, type);
38 return;
39 } else if (in_list->version.minorVersion() == type->version.minorVersion()) {
40 list[ii] = type;
41 return;
42 }
43 }
45}
46
48{
49 QMutexLocker lock(&m_mutex);
50 for (auto elementIt = m_typeHash.begin(); elementIt != m_typeHash.end(); ++elementIt)
51 QQmlMetaType::removeQQmlTypePrivate(elementIt.value(), type);
52}
53
54QQmlType QQmlTypeModule::findType(const QList<QQmlTypePrivate *> *types, QTypeRevision version)
55{
56 if (types) {
57 for (int ii = 0; ii < types->size(); ++ii)
58 if (types->at(ii)->version.minorVersion() <= version.minorVersion())
59 return QQmlType(types->at(ii));
60 }
61
62 return QQmlType();
63}
64
65void QQmlTypeModule::walkCompositeSingletons(const std::function<void(const QQmlType &)> &callback) const
66{
67 QMutexLocker lock(&m_mutex);
68 for (auto typeCandidates = m_typeHash.begin(), end = m_typeHash.end();
69 typeCandidates != end; ++typeCandidates) {
70 for (auto type: typeCandidates.value()) {
72 callback(QQmlType(type));
73 }
74 }
75}
76
bool testAndSetOrdered(T expectedValue, T newValue) noexcept
T loadRelaxed() const noexcept
qsizetype size() const noexcept
Definition qlist.h:397
iterator insert(qsizetype i, parameter_type t)
Definition qlist.h:488
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
void append(parameter_type t)
Definition qlist.h:458
\inmodule QtCore
Definition qmutex.h:313
static void removeQQmlTypePrivate(QQmlTypeContainer &container, const QQmlTypePrivate *reference)
void walkCompositeSingletons(const std::function< void(const QQmlType &)> &callback) const
void remove(const QQmlTypePrivate *type)
void addMinorVersion(quint8 minorVersion)
void add(QQmlTypePrivate *)
@ CompositeSingletonType
Definition qqmltype_p.h:164
MutableIterator begin()
MutableIterator end()
\inmodule QtCore
constexpr quint8 minorVersion() const
Returns the minor version encoded in the revision.
Combined button and popup list for selecting options.
GLuint GLuint end
GLsizei GLenum GLenum * types
GLenum type
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
unsigned char quint8
Definition qtypes.h:46
QList< int > list
[14]
QReadWriteLock lock
[0]