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
qfactorycacheregistration.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 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
5
6#include <QtCore/QMutex>
7
9
10#ifdef QT_USE_FACTORY_CACHE_REGISTRATION
11
12static QBasicMutex registrationMutex;
13static detail::QWinRTFactoryCacheRegistration *firstElement;
14
15detail::QWinRTFactoryCacheRegistration::QWinRTFactoryCacheRegistration(
16 QFunctionPointer clearFunction)
17 : m_clearFunction(clearFunction)
18{
19 QMutexLocker lock(&registrationMutex);
20
21 // forward pointers
22 m_next = std::exchange(firstElement, this);
23
24 // backward pointers
25 m_prevNext = &firstElement;
26 if (m_next)
27 m_next->m_prevNext = &m_next;
28}
29
30detail::QWinRTFactoryCacheRegistration::~QWinRTFactoryCacheRegistration()
31{
32 QMutexLocker lock(&registrationMutex);
33
34 *m_prevNext = m_next;
35
36 if (m_next)
37 m_next->m_prevNext = m_prevNext;
38}
39
40void detail::QWinRTFactoryCacheRegistration::clearAllCaches()
41{
42 QMutexLocker lock(&registrationMutex);
43
44 detail::QWinRTFactoryCacheRegistration *element;
45
46 for (element = firstElement; element != nullptr; element = element->m_next) {
47 element->m_clearFunction();
48 }
49}
50
51#endif
52
\inmodule QtCore
Definition qmutex.h:313
\inmodule QtCore
Definition qmutex.h:281
Combined button and popup list for selecting options.
QReadWriteLock lock
[0]