diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2023-07-12 17:57:58 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2023-07-13 08:24:02 +0000 |
| commit | d41db62154dfbf6cb78f6a64e962939a79eec03c (patch) | |
| tree | 37afed3bdfbc2d2abf82aeb5b307fda24f8a5979 /src/corelib/thread/qbasicfuturewatcher.cpp | |
| parent | 7c82a49e6fc4ec606cffa4fa8d3ceb42c87439cd (diff) | |
Move QBasicFutureWatcher behind the ABI boundary
... and out of QtPrivate.
No inline API requires it anymore, so move it into the only TU using
it. Can't move it into the unnamed namespace because of the friend
declaration in QFutureInterfaceBase.
Pick-to: 6.6
Change-Id: I27452960492bc1193a4d0eaeb2acd913d4dd02a5
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/thread/qbasicfuturewatcher.cpp')
| -rw-r--r-- | src/corelib/thread/qbasicfuturewatcher.cpp | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/src/corelib/thread/qbasicfuturewatcher.cpp b/src/corelib/thread/qbasicfuturewatcher.cpp deleted file mode 100644 index 2602995e8fa..00000000000 --- a/src/corelib/thread/qbasicfuturewatcher.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2023 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#include "qbasicfuturewatcher.h" -#include "qcoreapplication.h" -#include "qfutureinterface.h" -#include "qfutureinterface_p.h" - -#include <QtCore/private/qobject_p.h> - -QT_BEGIN_NAMESPACE - -namespace QtPrivate { - -class QBasicFutureWatcherPrivate : public QObjectPrivate, QFutureCallOutInterface -{ -public: - Q_DECLARE_PUBLIC(QBasicFutureWatcher) - - QFutureInterfaceBase future; - - void postCallOutEvent(const QFutureCallOutEvent &event) override; - void callOutInterfaceDisconnected() override; -}; - -void QBasicFutureWatcherPrivate::postCallOutEvent(const QFutureCallOutEvent &event) -{ - Q_Q(QBasicFutureWatcher); - if (q->thread() == QThread::currentThread()) { - // If we are in the same thread, don't queue up anything. - std::unique_ptr<QFutureCallOutEvent> clonedEvent(event.clone()); - QCoreApplication::sendEvent(q, clonedEvent.get()); - } else { - QCoreApplication::postEvent(q, event.clone()); - } -} - -void QBasicFutureWatcherPrivate::callOutInterfaceDisconnected() -{ - Q_Q(QBasicFutureWatcher); - QCoreApplication::removePostedEvents(q, QEvent::FutureCallOut); -} - -/* - * QBasicFutureWatcher is a more lightweight version of QFutureWatcher for internal use - */ -QBasicFutureWatcher::QBasicFutureWatcher(QObject *parent) - : QObject(*new QBasicFutureWatcherPrivate, parent) -{ -} - -QBasicFutureWatcher::~QBasicFutureWatcher() -{ - Q_D(QBasicFutureWatcher); - d->future.d->disconnectOutputInterface(d); -} - -void QBasicFutureWatcher::setFuture(QFutureInterfaceBase &fi) -{ - Q_D(QBasicFutureWatcher); - d->future = fi; - d->future.d->connectOutputInterface(d); -} - -bool QtPrivate::QBasicFutureWatcher::event(QEvent *event) -{ - if (event->type() == QEvent::FutureCallOut) { - QFutureCallOutEvent *callOutEvent = static_cast<QFutureCallOutEvent *>(event); - if (callOutEvent->callOutType == QFutureCallOutEvent::Finished) - emit finished(); - return true; - } - return QObject::event(event); -} - -} // namespace QtPrivate - -QT_END_NAMESPACE - -#include "moc_qbasicfuturewatcher.cpp" |
