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
qcoreapplication_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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
5#ifndef QCOREAPPLICATION_P_H
6#define QCOREAPPLICATION_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 "QtCore/qcoreapplication.h"
20#if QT_CONFIG(commandlineparser)
21#include "QtCore/qcommandlineoption.h"
22#endif
23#include "QtCore/qreadwritelock.h"
24#include "QtCore/qtranslator.h"
25#ifndef QT_NO_QOBJECT
26#include "private/qobject_p.h"
27#include "private/qlocking_p.h"
28#endif
29
30#ifdef Q_OS_MACOS
31#include "private/qcore_mac_p.h"
32#endif
33
35
37
38class QAbstractEventDispatcher;
39
40#ifndef QT_NO_QOBJECT
41class QEvent;
42#endif
43
44class Q_CORE_EXPORT QCoreApplicationPrivate
45#ifndef QT_NO_QOBJECT
46 : public QObjectPrivate
47#endif
48{
49 Q_DECLARE_PUBLIC(QCoreApplication)
50
51public:
52 enum Type : quint8 {
53 Tty,
54 Gui
55 };
56
57 QCoreApplicationPrivate(int &aargc, char **aargv);
58
59 // If not inheriting from QObjectPrivate: force this class to be polymorphic
60#ifdef QT_NO_QOBJECT
61 virtual
62#endif
63 ~QCoreApplicationPrivate();
64
65 void init();
66
67 QString appName() const;
68 QString appVersion() const;
69
70#ifdef Q_OS_DARWIN
71 static QString infoDictionaryStringProperty(const QString &propertyName);
72#endif
73
74#ifdef Q_OS_WINDOWS
75 void initDebuggingConsole();
76 void cleanupDebuggingConsole();
77#endif
78 static void initLocale();
79
80 static bool checkInstance(const char *method);
81
82#if QT_CONFIG(commandlineparser)
83 virtual void addQtOptions(QList<QCommandLineOption> *options);
84#endif
85
86#ifndef QT_NO_QOBJECT
87 bool sendThroughApplicationEventFilters(QObject *, QEvent *);
88 static bool sendThroughObjectEventFilters(QObject *, QEvent *);
89 static bool notify_helper(QObject *, QEvent *);
90 static inline void setEventSpontaneous(QEvent *e, bool spontaneous) { e->m_spont = spontaneous; }
91
92 virtual void createEventDispatcher();
93 virtual void eventDispatcherReady();
94 virtual bool compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents);
95 static void removePostedEvent(QEvent *);
96#ifdef Q_OS_WIN
97 static void removePostedTimerEvent(QObject *object, int timerId);
98#endif
99
100 QAtomicInt quitLockRef;
101 void ref();
102 void deref();
103 virtual bool canQuitAutomatically();
104 void quitAutomatically();
105 virtual void quit();
106
107 static QBasicAtomicPointer<QThread> theMainThread;
108 static QBasicAtomicPointer<void> theMainThreadId;
109 static QThread *mainThread();
110
111 static void sendPostedEvents(QObject *receiver, int event_type, QThreadData *data);
112
113 static void checkReceiverThread(QObject *receiver);
114 void cleanupThreadData();
115
116 struct QPostEventListLocker
117 {
118 QThreadData *threadData;
119 std::unique_lock<QMutex> locker;
120
121 void unlock() { locker.unlock(); }
122 };
123 static QPostEventListLocker lockThreadPostEventList(QObject *object);
124#endif // QT_NO_QOBJECT
125
126 int &argc;
127 char **argv;
128#if defined(Q_OS_WIN)
129 // store unmodified arguments for QCoreApplication::arguments()
130 int origArgc = 0;
131 std::unique_ptr<char *[]> origArgv;
132
133 bool consoleAllocated = false;
134 static void *mainInstanceHandle; // HINSTANCE without <windows.h>
135#endif
136
137 Type application_type = Tty;
138
139#ifndef QT_NO_QOBJECT
140 void execCleanup();
141
142 bool in_exec = false;
143 bool aboutToQuitEmitted = false;
144 bool threadData_clean = false;
145
146 static QAbstractEventDispatcher *eventDispatcher;
147 static bool is_app_running;
148 static bool is_app_closing;
149#endif
150#ifndef QT_NO_TRANSLATION
151 QTranslatorList translators;
152 QReadWriteLock translateMutex;
153 static bool isTranslatorInstalled(QTranslator *translator);
154#endif
155
156 static bool setuidAllowed;
157 static uint attribs;
158 static inline bool testAttribute(uint flag) { return attribs & (1 << flag); }
159
160 void processCommandLineArguments();
161 QString cachedApplicationFilePath;
162 QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging.
163
164#ifdef QT_NO_QOBJECT
165 QCoreApplication *q_ptr = nullptr;
166#endif
167};
168
169QT_END_NAMESPACE
170
171#endif // QCOREAPPLICATION_P_H
QPropertyBinding< T > makeBinding(const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
Constructs a binding evaluating to the underlying property's value, using a specified source location...
Definition qproperty.h:907
QPropertyBinding< T > binding() const
Returns the currently set binding of the underlying property.
Definition qproperty.h:911
T value() const
Returns the underlying property's current value.
Definition qproperty.h:949
void setValue(const T &value)
Sets the underlying property's value to value.
Definition qproperty.h:959
friend class QPropertyAlias
Definition qproperty.h:887
QBindable(QObject *obj, const QMetaProperty &property)
Definition qproperty.h:901
QPropertyBinding< T > setBinding(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, std::enable_if_t< std::is_invocable_v< Functor > > *=nullptr)
Definition qproperty.h:938
QBindable(const QUntypedBindable &b)
Definition qproperty.h:893
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &binding)
Sets the underlying property's binding to binding.
Definition qproperty.h:922
QBindable(QObject *obj, const char *property)
Definition qproperty.h:904
QPropertyBinding< T > takeBinding()
Removes the currently set binding of the underlying property and returns it.
Definition qproperty.h:916
\inmodule QtCore
\inmodule QtCore
Definition qproperty.h:1097
QObjectBindableProperty(const T &initialValue)
Constructs a property with the provided initialValue.
Definition qproperty.h:1128
QObjectBindableProperty()=default
typename QPropertyData< T >::rvalue_ref rvalue_ref
Definition qproperty.h:1124
typename QPropertyData< T >::value_type value_type
Definition qproperty.h:1122
QObjectBindableProperty(T &&initialValue)
Move-Constructs a property with the provided initialValue.
Definition qproperty.h:1129
typename QPropertyData< T >::arrow_operator_result arrow_operator_result
Definition qproperty.h:1125
QObjectBindableProperty(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, typename std::enable_if_t< std::is_invocable_r_v< T, Functor & > > *=nullptr)
Definition qproperty.h:1135
QObjectBindableProperty(const QPropertyBinding< T > &binding)
Definition qproperty.h:1130
typename QPropertyData< T >::parameter_type parameter_type
Definition qproperty.h:1123
\macro Q_OBJECT_BINDABLE_PROPERTY(containingClass, type, name, signal)
QPropertyBinding< T > binding() const
operator parameter_type() const
typename QPropertyData< T >::value_type value_type
QtPrivate::QPropertyBindingData & bindingData() const
QObjectCompatProperty & operator=(parameter_type newValue)
typename QPropertyData< T >::arrow_operator_result arrow_operator_result
typename QPropertyData< T >::parameter_type parameter_type
parameter_type value() const
QPropertyChangeHandler< Functor > onValueChanged(Functor f)
void setValue(parameter_type t)
void removeBindingUnlessInWrapper()
bool setBinding(const QUntypedPropertyBinding &newBinding)
QPropertyBinding< T > setBinding(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, std::enable_if_t< std::is_invocable_v< Functor > > *=nullptr)
arrow_operator_result operator->() const
QObjectCompatProperty(T &&initialValue)
QPropertyNotifier addNotifier(Functor f)
parameter_type operator*() const
QObjectCompatProperty(const T &initialValue)
QPropertyBinding< T > takeBinding()
QPropertyChangeHandler< Functor > subscribe(Functor f)
bool hasBinding() const
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &newBinding)
\macro Q_OBJECT_COMPAT_PROPERTY(containingClass, type, name, callback)
Definition qproperty.h:1363
QObjectComputedProperty()=default
parameter_type value() const
Definition qproperty.h:1381
\inmodule QtCore
Definition qproperty.h:133
QPropertyBinding(const QUntypedPropertyBinding &binding)
Definition qproperty.h:215
QPropertyBinding()=default
QPropertyBinding(Functor &&f, const QPropertyBindingSourceLocation &location)
Definition qproperty.h:209
\inmodule QtCore
Definition qproperty.h:302
\inmodule QtCore
Definition qproperty.h:71
static constexpr bool UseReferences
Definition qproperty.h:77
void setValueBypassingBindings(parameter_type v)
Sets the data value stored in this property to v.
Definition qproperty.h:91
QPropertyData()=default
QPropertyData(parameter_type t)
Definition qproperty.h:86
~QPropertyData()=default
parameter_type valueBypassingBindings() const
Returns the data stored in this property.
Definition qproperty.h:90
\inmodule QtCore
Definition qproperty.h:329
QUntypedPropertyData * aliasData
Definition qproperty.h:264
void(*)(QPropertyObserver *, QUntypedPropertyData *) ChangeHandler
Definition qproperty.h:246
ChangeHandler changeHandler
Definition qproperty.h:263
QPropertyBindingPrivate * binding
Definition qproperty.h:262
\inmodule QtCore
Definition qproperty.h:361
typename QPropertyData< T >::arrow_operator_result arrow_operator_result
Definition qproperty.h:387
QProperty(rvalue_ref initialValue)
Definition qproperty.h:391
void setValue(rvalue_ref newValue)
Definition qproperty.h:456
typename QPropertyData< T >::value_type value_type
Definition qproperty.h:384
QPropertyChangeHandler< Functor > subscribe(Functor f)
Definition qproperty.h:532
QPropertyBinding< T > takeBinding()
Disassociates the binding expression from this property and returns it.
Definition qproperty.h:519
bool hasBinding() const
Definition qproperty.h:512
bool setBinding(const QUntypedPropertyBinding &newBinding)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qproperty.h:491
friend void operator!=(const QProperty &, const QProperty< U > &) QPROPERTY_DECL_DELETED_EQ_OP
QPropertyNotifier addNotifier(Functor f)
Definition qproperty.h:540
typename QPropertyData< T >::rvalue_ref rvalue_ref
Definition qproperty.h:386
QPropertyChangeHandler< Functor > onValueChanged(Functor f)
Registers the given functor f as a callback that shall be called whenever the value of the property c...
Definition qproperty.h:525
QPropertyBinding< T > setBinding(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, std::enable_if_t< std::is_invocable_v< Functor > > *=nullptr)
Definition qproperty.h:501
void setValue(parameter_type newValue)
Assigns newValue to this property and removes the property's associated binding, if present.
Definition qproperty.h:465
QProperty()=default
Constructs a property with a default constructed instance of T.
QProperty(const QPropertyBinding< T > &binding)
Constructs a property that is tied to the provided binding expression.
Definition qproperty.h:392
parameter_type value() const
Returns the value of the property.
Definition qproperty.h:428
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &newBinding)
Associates the value of this property with the provided newBinding expression and returns the previou...
Definition qproperty.h:486
QProperty(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, typename std::enable_if_t< std::is_invocable_r_v< T, Functor & > > *=nullptr)
Definition qproperty.h:397
const QtPrivate::QPropertyBindingData & bindingData() const
Definition qproperty.h:546
typename QPropertyData< T >::parameter_type parameter_type
Definition qproperty.h:385
QProperty< T > & operator=(rvalue_ref newValue)
Definition qproperty.h:474
arrow_operator_result operator->() const
Definition qproperty.h:434
QProperty< T > & operator=(parameter_type newValue)
Assigns newValue to this property and returns a reference to this QProperty.
Definition qproperty.h:480
QPropertyBinding< T > binding() const
Returns the binding expression that is associated with this property.
Definition qproperty.h:514
parameter_type operator*() const
Definition qproperty.h:446
operator parameter_type() const
Definition qproperty.h:451
~QProperty()=default
Destroys the property.
QProperty(parameter_type initialValue)
Definition qproperty.h:390
RAII class around Qt::beginPropertyUpdateGroup()/QtendPropertyUpdateGroup().
Definition qproperty.h:59
~QTimerPrivate() override
QTimerPrivate(QTimer *qq)
Definition qtimer_p.h:28
void setIntervalDuration(std::chrono::nanoseconds nsec)
Definition qtimer_p.h:43
static constexpr int INV_TIMER
Definition qtimer_p.h:41
void setInterval(int msec)
Definition qtimer_p.h:53
bool isActive() const
Definition qtimer_p.h:59
const bool isQTimer
Definition qtimer_p.h:71
QTimerPrivate(std::chrono::nanoseconds nsec, QChronoTimer *qq)
Definition qtimer_p.h:33
Qt::TimerId id
Definition qtimer_p.h:61
\inmodule QtCore
Definition qtimer.h:21
\inmodule QtCore
Definition qproperty.h:751
QUntypedPropertyBinding binding() const
Returns the underlying property's binding if there is any, or a default constructed QUntypedPropertyB...
Definition qproperty.h:831
QUntypedPropertyBinding makeBinding(const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
Creates a binding returning the underlying properties' value, using a specified source location.
Definition qproperty.h:775
bool hasBinding() const
Returns true if the underlying property has a binding.
Definition qproperty.h:861
constexpr QUntypedBindable()=default
Default-constructs a QUntypedBindable.
QMetaType metaType() const
Definition qproperty.h:866
const QtPrivate::QBindableInterface * iface
Definition qproperty.h:755
QPropertyChangeHandler< Functor > onValueChanged(Functor f) const
Installs f as a change handler.
Definition qproperty.h:809
QUntypedPropertyBinding takeBinding()
Removes the currently set binding from the property and returns it.
Definition qproperty.h:780
QPropertyNotifier addNotifier(Functor f)
Installs f as a change handler.
Definition qproperty.h:824
QUntypedPropertyData * data
Definition qproperty.h:754
bool isBindable() const
Definition qproperty.h:772
bool isValid() const
Returns true if the QUntypedBindable is valid.
Definition qproperty.h:771
bool setBinding(const QUntypedPropertyBinding &binding)
Sets the underlying property's binding to binding.
Definition qproperty.h:842
bool isReadOnly() const
Definition qproperty.h:773
QUntypedBindable(Property *p)
Constructs a QUntypedBindable from the property property.
Definition qproperty.h:766
QPropertyChangeHandler< Functor > subscribe(Functor f) const
Behaves like a call to f followed by onValueChanged(f),.
Definition qproperty.h:817
constexpr QUntypedBindable(QUntypedPropertyData *d, const QtPrivate::QBindableInterface *i)
Definition qproperty.h:756
void observe(QPropertyObserver *observer) const
Definition qproperty.h:797
\inmodule QtCore
Definition qproperty.h:160
static constexpr QBindableInterface iface
Definition qproperty.h:615
QPropertyBindingData & bindingData()
friend class QT_PREPEND_NAMESPACE(QUntypedBindable)
const QMetaProperty & metaProperty() const
static QPropertyAdaptorSlotObject * cast(QSlotObjectBase *ptr, int propertyIndex)
const QPropertyBindingData & bindingData() const
Combined button and popup list for selecting options.
const T & const_reference()
constexpr bool has_ostream_operator_v
constexpr bool is_dereferenceable_v
constexpr bool has_operator_equal_v
constexpr bool has_stream_operator_v
constexpr bool has_operator_compare_three_way_v
constexpr bool has_istream_operator_v
std::disjunction< std::is_base_of< Container, T >, QTypeTraits::has_operator_equal< T > > has_operator_equal_container
std::disjunction< std::is_base_of< Container, T >, QTypeTraits::has_operator_less_than< T > > has_operator_less_than_container
constexpr bool has_operator_compare_three_way_with_v
constexpr bool has_operator_less_than_v
void printMetaTypeMismatch(QMetaType actual, QMetaType expected)
void printUnsuitableBindableWarning(QAnyStringView prefix, BindableWarnings::Reason reason)
Q_CORE_EXPORT void printSignalArgumentsWithCustomGetter()
void setter(QUntypedPropertyData *d, const void *value)
void getter(const QUntypedPropertyData *d, void *value)
bool bindingWrapper(QMetaType type, QUntypedPropertyData *d, QtPrivate::QPropertyBindingFunction binding, QUntypedPropertyData *temp, void *value)
QUntypedPropertyBinding setBinding(QUntypedPropertyData *d, const QUntypedPropertyBinding &binding)
Definition qproperty.h:707
constexpr QBindableInterface iface
Definition qproperty.h:726
bool bindingWrapper(QMetaType type, QUntypedPropertyData *d, QtPrivate::QPropertyBindingFunction binding)
Definition qproperty.h:696
QUntypedPropertyBinding makeBinding(const QUntypedPropertyData *d, const QPropertyBindingSourceLocation &location)
Definition qproperty.h:713
void setObserver(const QUntypedPropertyData *d, QPropertyObserver *observer)
void assertObjectType(QObjectPrivate *d)
Definition qobject_p.h:251
Q_CORE_EXPORT bool isAnyBindingEvaluating()
Q_CORE_EXPORT void restoreBindingStatus(BindingEvaluationState *status)
constexpr bool is_standard_or_extended_integer_type_v
const QObject * getQObject(const QObjectPrivate *d)
Definition qobject_p.h:246
Q_CORE_EXPORT bool isPropertyInBindingWrapper(const QUntypedPropertyData *property)
Definition qcompare.h:111
auto makePropertyBinding(Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, std::enable_if_t< std::is_invocable_v< Functor > > *=nullptr)
Definition qproperty.h:222
Q_CORE_EXPORT void beginPropertyUpdateGroup()
QPropertyBinding< PropertyType > makePropertyBinding(const QProperty< PropertyType > &otherProperty, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION)
Definition qproperty.h:576
Q_CORE_EXPORT void endPropertyUpdateGroup()
#define __has_include(x)
QT_BEGIN_NAMESPACE typedef QList< QTranslator * > QTranslatorList
#define QT_CONCAT(B, M, m, u)
Definition qobject_p.h:43
QBindingStorage * qGetBindingStorage(QObjectPrivate *o)
Definition qobject_p.h:456
QBindingStorage * qGetBindingStorage(QObjectPrivate::ExtraData *ed)
Definition qobject_p.h:464
const QBindingStorage * qGetBindingStorage(const QObjectPrivate *o)
Definition qobject_p.h:452
#define QPROPERTY_DECL_DELETED_EQ_OP
Definition qproperty.h:419
#define Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(...)
Definition qproperty.h:1356
#define QT_PROPERTY_DEFAULT_BINDING_LOCATION
Definition qproperty.h:48
#define Q_OBJECT_COMPUTED_PROPERTY(Class, Type, name, ...)
Definition qproperty.h:1445
#define Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(...)
constexpr T qExchange(T &t, U &&newValue) noexcept(std::conjunction_v< std::is_nothrow_move_constructible< T >, std::is_nothrow_assignable< T &, U > >)
#define QSEIT_EXCLUDE(X)
QBindingObserverPtr()=default
QPropertyObserver * operator->()
QPropertyBindingPrivate * binding() const noexcept
static QPropertyProxyBindingData * proxyData(QtPrivate::QPropertyBindingData *ptr)
static void fixupAfterMove(QtPrivate::QPropertyBindingData *ptr)
Q_ALWAYS_INLINE void addObserver(QPropertyObserver *observer)
Definition qproperty.cpp:41
const QtPrivate::QPropertyBindingData * ptr
Definition qproperty_p.h:75
static QPropertyBindingDataPointer get(QProperty< T > &property)
Definition qproperty_p.h:97
QPropertyBindingPrivate * binding() const
Definition qproperty_p.h:77
void setObservers(QPropertyObserver *observer)
Definition qproperty_p.h:82
QPropertyObserverPointer firstObserver() const
void setFirstObserver(QPropertyObserver *observer)
QPropertyObserver * next() const
void noSelfDependencies(QPropertyBindingPrivate *binding)
void notify(QUntypedPropertyData *propertyDataPtr)
QPropertyBindingPrivate * binding() const
void evaluateBindings(PendingBindingObserverList &bindingObservers, QBindingStatus *status)
void observeProperty(QPropertyBindingDataPointer property)
QPropertyObserver * ptr
QPropertyObserverPointer nextObserver() const
void setBindingToNotify_unsafe(QPropertyBindingPrivate *binding)
void setChangeHandler(QPropertyObserver::ChangeHandler changeHandler)
void setBindingToNotify(QPropertyBindingPrivate *binding)
void(* BeginCallback)(QObject *caller, int signal_or_method_index, void **argv)
Definition qobject_p.h:64
BeginCallback slot_begin_callback
Definition qobject_p.h:67
EndCallback slot_end_callback
Definition qobject_p.h:69
EndCallback signal_end_callback
Definition qobject_p.h:68
BeginCallback signal_begin_callback
Definition qobject_p.h:66
void(* EndCallback)(QObject *caller, int signal_or_method_index)
Definition qobject_p.h:65
static QtPrivate::QBindableInterface const * getInterface(const QUntypedBindable &bindable)
static QUntypedPropertyData * getPropertyData(const QUntypedBindable &bindable)
QPropertyBindingPrivate * binding
QVarLengthArray< const QPropertyBindingData *, 8 > alreadyCaptureProperties
BindingEvaluationState(QPropertyBindingPrivate *binding, QBindingStatus *status)
BindingEvaluationState * previousState
BindingEvaluationState ** currentState
QtPrivate::BindingEvaluationState ** currentlyEvaluatingBindingList
CompatPropertySafePoint * previousState
CompatPropertySafePoint ** currentState
QUntypedPropertyData * property
QtPrivate::BindingEvaluationState * bindingState
void(*)(const QUntypedPropertyData *d, void *value) Getter
Definition qproperty.h:590
void(*)(const QUntypedPropertyData *d, QPropertyObserver *observer) SetObserver
Definition qproperty.h:595
void(*)(QUntypedPropertyData *d, const void *value) Setter
Definition qproperty.h:591
static constexpr quintptr MetaTypeAccessorFlag
Definition qproperty.h:605