QBasicFutureWatcher: get rid of the Private

It's not needed anymore, because the class is no longer part of the ABI.

Change-Id: Idfacc6023288ce603b30ab5aa904106e8c850444
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 3fb0208d4b164f10131aeb48774a099cae4f8415)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-07-13 10:18:46 +02:00 committed by Qt Cherry-pick Bot
parent 2634898e2e
commit 220f86d1ee

View File

@ -45,11 +45,9 @@ const auto suspendingOrSuspended =
} // unnamed namespace } // unnamed namespace
class QBasicFutureWatcherPrivate; class QBasicFutureWatcher : public QObject, QFutureCallOutInterface
class QBasicFutureWatcher : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DECLARE_PRIVATE(QBasicFutureWatcher)
public: public:
explicit QBasicFutureWatcher(QObject *parent = nullptr); explicit QBasicFutureWatcher(QObject *parent = nullptr);
~QBasicFutureWatcher() override; ~QBasicFutureWatcher() override;
@ -60,56 +58,47 @@ public:
Q_SIGNALS: Q_SIGNALS:
void finished(); void finished();
};
class QBasicFutureWatcherPrivate : public QObjectPrivate, QFutureCallOutInterface
{
public:
Q_DECLARE_PUBLIC(QBasicFutureWatcher)
private:
QFutureInterfaceBase future; QFutureInterfaceBase future;
void postCallOutEvent(const QFutureCallOutEvent &event) override; void postCallOutEvent(const QFutureCallOutEvent &event) override;
void callOutInterfaceDisconnected() override; void callOutInterfaceDisconnected() override;
}; };
void QBasicFutureWatcherPrivate::postCallOutEvent(const QFutureCallOutEvent &event) void QBasicFutureWatcher::postCallOutEvent(const QFutureCallOutEvent &event)
{ {
Q_Q(QBasicFutureWatcher); if (thread() == QThread::currentThread()) {
if (q->thread() == QThread::currentThread()) {
// If we are in the same thread, don't queue up anything. // If we are in the same thread, don't queue up anything.
std::unique_ptr<QFutureCallOutEvent> clonedEvent(event.clone()); std::unique_ptr<QFutureCallOutEvent> clonedEvent(event.clone());
QCoreApplication::sendEvent(q, clonedEvent.get()); QCoreApplication::sendEvent(this, clonedEvent.get());
} else { } else {
QCoreApplication::postEvent(q, event.clone()); QCoreApplication::postEvent(this, event.clone());
} }
} }
void QBasicFutureWatcherPrivate::callOutInterfaceDisconnected() void QBasicFutureWatcher::callOutInterfaceDisconnected()
{ {
Q_Q(QBasicFutureWatcher); QCoreApplication::removePostedEvents(this, QEvent::FutureCallOut);
QCoreApplication::removePostedEvents(q, QEvent::FutureCallOut);
} }
/* /*
* QBasicFutureWatcher is a more lightweight version of QFutureWatcher for internal use * QBasicFutureWatcher is a more lightweight version of QFutureWatcher for internal use
*/ */
QBasicFutureWatcher::QBasicFutureWatcher(QObject *parent) QBasicFutureWatcher::QBasicFutureWatcher(QObject *parent)
: QObject(*new QBasicFutureWatcherPrivate, parent) : QObject(parent)
{ {
} }
QBasicFutureWatcher::~QBasicFutureWatcher() QBasicFutureWatcher::~QBasicFutureWatcher()
{ {
Q_D(QBasicFutureWatcher); future.d->disconnectOutputInterface(this);
d->future.d->disconnectOutputInterface(d);
} }
void QBasicFutureWatcher::setFuture(QFutureInterfaceBase &fi) void QBasicFutureWatcher::setFuture(QFutureInterfaceBase &fi)
{ {
Q_D(QBasicFutureWatcher); future = fi;
d->future = fi; future.d->connectOutputInterface(this);
d->future.d->connectOutputInterface(d);
} }
bool QBasicFutureWatcher::event(QEvent *event) bool QBasicFutureWatcher::event(QEvent *event)