Get rid of hasPendingEvents() and flush()

They are unused.

Change-Id: I77383f2be45551401ed9c2f88285511134cc8b0d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Lars Knoll 2020-08-31 13:39:48 +02:00
parent 2caa2faf01
commit 75d1d2a913
25 changed files with 6 additions and 152 deletions

View File

@ -210,8 +210,6 @@ QAbstractEventDispatcher *QAbstractEventDispatcher::instance(QThread *thread)
\b{Note:} This function does not process events continuously; it
returns after all available events are processed.
\sa hasPendingEvents()
*/
/*!
@ -223,14 +221,6 @@ QAbstractEventDispatcher *QAbstractEventDispatcher::instance(QThread *thread)
events. For timers and system level events, the situation is unknown.
*/
/*! \fn bool QAbstractEventDispatcher::hasPendingEvents()
\deprecated
Returns \c true if there is an event waiting; otherwise returns false. This
function is an implementation detail for
QCoreApplication::hasPendingEvents() and must not be called directly.
*/
/*!
\fn void QAbstractEventDispatcher::registerSocketNotifier(QSocketNotifier *notifier)
@ -326,13 +316,6 @@ int QAbstractEventDispatcher::registerTimer(int interval, Qt::TimerType timerTyp
return from processEvents() as soon as possible.
*/
/*! \fn void QAbstractEventDispatcher::flush()
\deprecated
Depending from the event dispatcher implementation does nothing or
calls QApplication::sendPostedEvents().
*/
// ### DOC: Are these called when the _application_ starts/stops or just
// when the current _event loop_ starts/stops?
/*!

View File

@ -76,7 +76,6 @@ public:
static QAbstractEventDispatcher *instance(QThread *thread = nullptr);
virtual bool processEvents(QEventLoop::ProcessEventsFlags flags) = 0;
virtual bool hasPendingEvents() = 0; // ### Qt6: remove, mark final or make protected
virtual void registerSocketNotifier(QSocketNotifier *notifier) = 0;
virtual void unregisterSocketNotifier(QSocketNotifier *notifier) = 0;
@ -97,7 +96,6 @@ public:
virtual void wakeUp() = 0;
virtual void interrupt() = 0;
virtual void flush() = 0; // ### Qt6: remove, mark final or make protected
virtual void startingUp();
virtual void closingDown();

View File

@ -1251,7 +1251,7 @@ bool QCoreApplication::closingDown()
\threadsafe
\sa exec(), QTimer, QEventLoop::processEvents(), flush(), sendPostedEvents()
\sa exec(), QTimer, QEventLoop::processEvents(), sendPostedEvents()
*/
void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags)
{
@ -1641,7 +1641,7 @@ bool QCoreApplication::compressEvent(QEvent *event, QObject *receiver, QPostEven
\note This method must be called from the thread in which its QObject
parameter, \a receiver, lives.
\sa flush(), postEvent()
\sa postEvent()
*/
void QCoreApplication::sendPostedEvents(QObject *receiver, int event_type)
{

View File

@ -259,8 +259,7 @@ QEventLoop *QEventDispatcherCoreFoundation::currentEventLoop() const
function should wait only if there were no events ready,
and _then_ process all newly queued/available events.
These notes apply to other function in this class as well, such as
hasPendingEvents().
These notes apply to other function in this class as well.
*/
bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlags flags)
{
@ -499,21 +498,6 @@ void QEventDispatcherCoreFoundation::handleRunLoopActivity(CFRunLoopActivity act
}
}
bool QEventDispatcherCoreFoundation::hasPendingEvents()
{
// There doesn't seem to be any API on iOS to peek into the other sources
// to figure out if there are pending non-Qt events. As a workaround, we
// assume that if the run-loop is currently blocking and waiting for a
// source to signal then there are no system-events pending. If this
// function is called from the main thread then the second clause
// of the condition will always be true, as the run loop is
// never waiting in that case. The function would be more aptly named
// 'maybeHasPendingEvents' in our case.
extern uint qGlobalPostedEventsCount();
return qGlobalPostedEventsCount() || !CFRunLoopIsWaiting(m_runLoop);
}
void QEventDispatcherCoreFoundation::wakeUp()
{
if (m_processEvents.processedPostedEvents && !(m_processEvents.flags & QEventLoop::EventLoopExec)) {
@ -544,11 +528,6 @@ void QEventDispatcherCoreFoundation::interrupt()
CFRunLoopStop(m_runLoop);
}
void QEventDispatcherCoreFoundation::flush()
{
// X11 only.
}
#pragma mark - Socket notifiers
void QEventDispatcherCoreFoundation::registerSocketNotifier(QSocketNotifier *notifier)

View File

@ -214,7 +214,6 @@ public:
~QEventDispatcherCoreFoundation();
bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
bool hasPendingEvents() override;
void registerSocketNotifier(QSocketNotifier *notifier) override;
void unregisterSocketNotifier(QSocketNotifier *notifier) override;
@ -228,7 +227,6 @@ public:
void wakeUp() override;
void interrupt() override;
void flush() override;
protected:
QEventLoop *currentEventLoop() const;

View File

@ -432,12 +432,6 @@ bool QEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
return result;
}
bool QEventDispatcherGlib::hasPendingEvents()
{
Q_D(QEventDispatcherGlib);
return g_main_context_pending(d->mainContext);
}
void QEventDispatcherGlib::registerSocketNotifier(QSocketNotifier *notifier)
{
Q_ASSERT(notifier);
@ -592,10 +586,6 @@ void QEventDispatcherGlib::wakeUp()
g_main_context_wakeup(d->mainContext);
}
void QEventDispatcherGlib::flush()
{
}
bool QEventDispatcherGlib::versionSupported()
{
#if !defined(GLIB_MAJOR_VERSION) || !defined(GLIB_MINOR_VERSION) || !defined(GLIB_MICRO_VERSION)

View File

@ -71,7 +71,6 @@ public:
~QEventDispatcherGlib();
bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
bool hasPendingEvents() override;
void registerSocketNotifier(QSocketNotifier *socketNotifier) final;
void unregisterSocketNotifier(QSocketNotifier *socketNotifier) final;
@ -85,7 +84,6 @@ public:
void wakeUp() final;
void interrupt() final;
void flush() final;
static bool versionSupported();

View File

@ -519,12 +519,6 @@ bool QEventDispatcherUNIX::processEvents(QEventLoop::ProcessEventsFlags flags)
return (nevents > 0);
}
bool QEventDispatcherUNIX::hasPendingEvents()
{
extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
return qGlobalPostedEventsCount();
}
int QEventDispatcherUNIX::remainingTime(int timerId)
{
#ifndef QT_NO_DEBUG
@ -551,9 +545,6 @@ void QEventDispatcherUNIX::interrupt()
wakeUp();
}
void QEventDispatcherUNIX::flush()
{ }
QT_END_NAMESPACE
#include "moc_qeventdispatcher_unix_p.cpp"

View File

@ -106,7 +106,6 @@ public:
~QEventDispatcherUNIX();
bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
bool hasPendingEvents() override;
void registerSocketNotifier(QSocketNotifier *notifier) final;
void unregisterSocketNotifier(QSocketNotifier *notifier) final;
@ -120,7 +119,6 @@ public:
void wakeUp() override;
void interrupt() final;
void flush() override;
protected:
QEventDispatcherUNIX(QEventDispatcherUNIXPrivate &dd, QObject *parent = nullptr);

View File

@ -612,12 +612,6 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
return retVal;
}
bool QEventDispatcherWin32::hasPendingEvents()
{
MSG msg;
return qGlobalPostedEventsCount() || PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
}
void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier)
{
Q_ASSERT(notifier);
@ -970,9 +964,6 @@ void QEventDispatcherWin32::interrupt()
wakeUp();
}
void QEventDispatcherWin32::flush()
{ }
void QEventDispatcherWin32::startingUp()
{ }

View File

@ -80,7 +80,6 @@ public:
~QEventDispatcherWin32();
bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags) override;
bool hasPendingEvents() override;
void registerSocketNotifier(QSocketNotifier *notifier) override;
void unregisterSocketNotifier(QSocketNotifier *notifier) override;
@ -98,7 +97,6 @@ public:
void wakeUp() override;
void interrupt() override;
void flush() override;
void startingUp() override;
void closingDown() override;

View File

@ -464,7 +464,6 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME
postEvent(),
sendPostedEvents(),
removePostedEvents(),
hasPendingEvents(),
notify().
\row

View File

@ -64,16 +64,4 @@ bool QUnixEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags
return QWindowSystemInterface::sendWindowSystemEvents(flags) || didSendEvents;
}
bool QUnixEventDispatcherQPA::hasPendingEvents()
{
extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
return qGlobalPostedEventsCount() || QWindowSystemInterface::windowSystemEventsQueued();
}
void QUnixEventDispatcherQPA::flush()
{
if(qApp)
qApp->sendPostedEvents();
}
QT_END_NAMESPACE

View File

@ -65,9 +65,6 @@ public:
~QUnixEventDispatcherQPA();
bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
bool hasPendingEvents() override;
void flush() override;
};
QT_END_NAMESPACE

View File

@ -115,7 +115,6 @@ public:
~QCocoaEventDispatcher();
bool processEvents(QEventLoop::ProcessEventsFlags flags);
bool hasPendingEvents();
void registerSocketNotifier(QSocketNotifier *notifier);
void unregisterSocketNotifier(QSocketNotifier *notifier);
@ -129,7 +128,6 @@ public:
void wakeUp();
void interrupt();
void flush();
static void clearCurrentThreadCocoaEventDispatcherInterruptFlag();

View File

@ -288,13 +288,6 @@ void QCocoaEventDispatcher::unregisterSocketNotifier(QSocketNotifier *notifier)
d->cfSocketNotifier.unregisterSocketNotifier(notifier);
}
bool QCocoaEventDispatcher::hasPendingEvents()
{
extern uint qGlobalPostedEventsCount();
extern bool qt_is_gui_used; //qapplication.cpp
return qGlobalPostedEventsCount() || (qt_is_gui_used && !CFRunLoopIsWaiting(CFRunLoopGetMain()));
}
static bool isUserInputEvent(NSEvent* event)
{
switch ([event type]) {
@ -969,9 +962,6 @@ void QCocoaEventDispatcher::interrupt()
d->cancelWaitForMoreEvents();
}
void QCocoaEventDispatcher::flush()
{ }
// QTBUG-56746: The behavior of processEvents() has been changed to not clear
// the interrupt flag. Use this function to clear it.
void QCocoaEventDispatcher::clearCurrentThreadCocoaEventDispatcherInterruptFlag()

View File

@ -86,19 +86,6 @@ public:
return QWindowSystemInterface::sendWindowSystemEvents(flags) || didSendEvents;
}
bool hasPendingEvents() override
{
return BaseEventDispatcher::hasPendingEvents()
|| QWindowSystemInterface::windowSystemEventsQueued();
}
void flush() override
{
if (qApp)
qApp->sendPostedEvents();
BaseEventDispatcher::flush();
}
};
QOffscreenIntegration::QOffscreenIntegration()

View File

@ -30,6 +30,7 @@
#include "qwasmeventdispatcher.h"
#include <QtCore/qcoreapplication.h>
#include <QtGui/qpa/qwindowsysteminterface.h>
#include <emscripten.h>
@ -144,7 +145,8 @@ void QWasmEventDispatcher::doMaintainTimers()
// native timer.
// Schedule a zero-timer to continue processing any pending events.
if (!m_hasZeroTimer && hasPendingEvents()) {
extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
if (!m_hasZeroTimer && (qGlobalPostedEventsCount() || QWindowSystemInterface::windowSystemEventsQueued())) {
auto callback = [](void *eventDispatcher) {
QWasmEventDispatcher *that = static_cast<QWasmEventDispatcher *>(eventDispatcher);
that->m_hasZeroTimer = false;

View File

@ -63,18 +63,6 @@ bool QXcbUnixEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags
return QWindowSystemInterface::sendWindowSystemEvents(flags) || didSendEvents;
}
bool QXcbUnixEventDispatcher::hasPendingEvents()
{
extern uint qGlobalPostedEventsCount();
return qGlobalPostedEventsCount() || QWindowSystemInterface::windowSystemEventsQueued();
}
void QXcbUnixEventDispatcher::flush()
{
if (qApp)
qApp->sendPostedEvents();
}
#if QT_CONFIG(glib)
struct XcbEventSource
{

View File

@ -60,12 +60,6 @@ public:
~QXcbUnixEventDispatcher();
bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
// Maybe some user code depends on deprecated QUnixEventDispatcherQPA::
// hasPendingEvents() / flush() implementation, so keep it around until
// Qt 6. These methods are deprecated in QAbstractEventDispatcher.
bool hasPendingEvents() override; // ### Qt 6 remove
void flush() override; // ### Qt 6 remove
private:
QXcbConnection *m_connection;
};

View File

@ -267,7 +267,6 @@ void QApplicationPrivate::createEventDispatcher()
postEvent(),
sendPostedEvents(),
removePostedEvents(),
hasPendingEvents(),
notify().
\row

View File

@ -668,9 +668,6 @@ public:
QCoreApplication::sendPostedEvents();
return false;
}
bool hasPendingEvents() {
return qGlobalPostedEventsCount();
}
void registerSocketNotifier(QSocketNotifier *) {}
void unregisterSocketNotifier(QSocketNotifier *) {}
void registerTimer(int , int , Qt::TimerType, QObject *) {}
@ -680,7 +677,6 @@ public:
int remainingTime(int) { return 0; }
void wakeUp() {}
void interrupt() {}
void flush() {}
#ifdef Q_OS_WIN
bool registerEventNotifier(QWinEventNotifier *) { return false; }

View File

@ -1219,9 +1219,6 @@ public:
QCoreApplication::sendPostedEvents();
return false;
}
bool hasPendingEvents() {
return qGlobalPostedEventsCount();
}
void registerSocketNotifier(QSocketNotifier *) {}
void unregisterSocketNotifier(QSocketNotifier *) {}
void registerTimer(int, int, Qt::TimerType, QObject *) {}
@ -1231,7 +1228,6 @@ public:
int remainingTime(int) { return 0; }
void wakeUp() {}
void interrupt() {}
void flush() {}
#ifdef Q_OS_WIN
bool registerEventNotifier(QWinEventNotifier *) { return false; }

View File

@ -39,8 +39,6 @@ public:
TestEventDispatcher(QObject* parent =0)
: QAbstractEventDispatcher(parent)
{}
void flush() {}
bool hasPendingEvents() { return false; }
void interrupt() {}
bool processEvents(QEventLoop::ProcessEventsFlags) { return false; }
void registerSocketNotifier(QSocketNotifier*) {}

View File

@ -39,8 +39,6 @@ public:
TestEventDispatcher(QObject* parent =0)
: QAbstractEventDispatcher(parent)
{}
void flush() {}
bool hasPendingEvents() { return false; }
void interrupt() {}
bool processEvents(QEventLoop::ProcessEventsFlags) { return false; }
void registerSocketNotifier(QSocketNotifier*) {}