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
qqmldelayedcallqueue_p.h
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
5#ifndef QQMLDELAYEDCALLQUEUE_P_H
6#define QQMLDELAYEDCALLQUEUE_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/qglobal.h>
20#include <QtCore/qobject.h>
21#include <QtCore/qmetaobject.h>
22#include <QtCore/qmetatype.h>
23#include <private/qqmlguard_p.h>
24#include <private/qv4context_p.h>
25
26QT_BEGIN_NAMESPACE
27
28class QQmlDelayedCallQueue : public QObject
29{
30 Q_OBJECT
31public:
32 QQmlDelayedCallQueue();
33 ~QQmlDelayedCallQueue() override;
34
35 void init(QV4::ExecutionEngine *);
36
37 static QV4::ReturnedValue addUniquelyAndExecuteLater(QV4::ExecutionEngine *engine,
38 QQmlV4FunctionPtr args);
39
40public Q_SLOTS:
41 void ticked();
42
43private:
44 struct DelayedFunctionCall
45 {
46 DelayedFunctionCall() {}
47 DelayedFunctionCall(QV4::PersistentValue function, QObject *explicitObject)
48 : m_function(function), m_explicitObject(explicitObject), m_guarded(false),
49 m_hasExplicitObject(explicitObject != nullptr) { }
50
51 bool matchesExplicitObject(const QObject *explicitObject) const
52 {
53 return m_hasExplicitObject == (explicitObject != nullptr)
54 && m_explicitObject.data() == explicitObject;
55 }
56
57 bool argumentsEqual(QQmlV4FunctionPtr args, int offset) const;
58
59 void execute(QV4::ExecutionEngine *engine) const;
60
61 QV4::PersistentValue m_function;
62 QV4::PersistentValue m_args;
63 QQmlGuard<QObject> m_objectGuard;
64 // The object passed to Qt.callLater(object, function, ...)
65 QQmlGuard<QObject> m_explicitObject;
66 bool m_guarded;
67 bool m_hasExplicitObject = false;
68 };
69
70 void storeAnyArguments(DelayedFunctionCall& dfc, QQmlV4FunctionPtr args, int offset, QV4::ExecutionEngine *engine);
71 void executeAllExpired_Later();
72
73 QV4::ExecutionEngine *m_engine;
74 QList<DelayedFunctionCall> m_delayedFunctionCalls;
75 QMetaMethod m_tickedMethod;
76 bool m_callbackOutstanding;
77};
78
80
81#endif // QQMLDELAYEDCALLQUEUE_P_H
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE bool isAlive(const QObject *object)
static bool isAliveInValidContext(const QObject *object)