Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qbasicfuturewatcher.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 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#include "qcoreapplication.h"
6#include "qfutureinterface.h"
8
9#include <QtCore/private/qobject_p.h>
10
12
13namespace QtPrivate {
14
16{
17public:
18 Q_DECLARE_PUBLIC(QBasicFutureWatcher)
19
21
22 void postCallOutEvent(const QFutureCallOutEvent &event) override;
23 void callOutInterfaceDisconnected() override;
24};
25
27{
29 if (q->thread() == QThread::currentThread()) {
30 // If we are in the same thread, don't queue up anything.
31 std::unique_ptr<QFutureCallOutEvent> clonedEvent(event.clone());
32 QCoreApplication::sendEvent(q, clonedEvent.get());
33 } else {
35 }
36}
37
39{
42}
43
44/*
45 * QBasicFutureWatcher is a more lightweight version of QFutureWatcher for internal use
46 */
49{
50}
51
53{
55 d->future.d->disconnectOutputInterface(d);
56}
57
59{
61 d->future = fi;
62 d->future.d->connectOutputInterface(d);
63}
64
66{
67 if (event->type() == QEvent::FutureCallOut) {
68 QFutureCallOutEvent *callOutEvent = static_cast<QFutureCallOutEvent *>(event);
69 if (callOutEvent->callOutType == QFutureCallOutEvent::Finished)
70 emit finished();
71 return true;
72 }
73 return QObject::event(event);
74}
75
76} // namespace QtPrivate
77
79
80#include "moc_qbasicfuturewatcher.cpp"
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static void removePostedEvents(QObject *receiver, int eventType=0)
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
\inmodule QtCore
Definition qcoreevent.h:45
@ FutureCallOut
Definition qcoreevent.h:223
QObject * parent
Definition qobject.h:61
\inmodule QtCore
Definition qobject.h:90
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition qobject.cpp:1363
static QThread * currentThread()
Definition qthread.cpp:966
void postCallOutEvent(const QFutureCallOutEvent &event) override
bool event(QEvent *event) override
This virtual function receives events to an object and should return true if the event e was recogniz...
void setFuture(QFutureInterfaceBase &fi)
QBasicFutureWatcher(QObject *parent=nullptr)
Combined button and popup list for selecting options.
\macro QT_NAMESPACE
struct _cl_event * event
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
#define emit
QFileInfo fi("c:/temp/foo")
[newstuff]