7#include <private/qthread_p.h>
12#include <QtCore/qlist.h>
13#include <QtCore/qpair.h>
47 if (
p->pollfd.revents & G_IO_NVAL) {
49 const char *
const t[] = {
"Read",
"Write",
"Exception" };
50 qWarning(
"QSocketNotifier: Invalid socket %d and type '%s', disabling...",
51 p->pollfd.fd,
t[
int(
p->socketNotifier->type())]);
53 p->socketNotifier->setEnabled(
false);
68 for (
src->activeNotifierPos = 0;
src->activeNotifierPos <
src->pollfds.size();
69 ++
src->activeNotifierPos) {
72 if ((
p->pollfd.revents &
p->pollfd.events) != 0)
98 timespec tv = { 0l, 0l };
100 *
timeout = (tv.tv_sec * 1000) + ((tv.tv_nsec + 999999) / 1000 / 1000);
109 if (
src->timerList.isEmpty()
113 return !
src->timerList.hasPendingTimers();
123 if (
src->runWithIdlePriority) {
135 if (
src->runWithIdlePriority)
223 const bool canWait =
data->canWaitLocked();
228 return !canWait ||
source->d->wakeUpCalled;
241 source->d->runTimersOnceWithNormalPriority();
258#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 32
262 if (!g_thread_supported())
279#if GLIB_CHECK_VERSION (2, 22, 0)
285 g_source_set_name(
source,
"[Qt] GPostEventSource");
295 g_source_set_name(
source,
"[Qt] GSocketNotifierSource");
303 g_source_set_name(
source,
"[Qt] GTimerSource");
312 g_source_set_name(
source,
"[Qt] GIdleTimerSource");
339 d->timerSource->timerList.~QTimerInfoList();
340 g_source_destroy(&
d->timerSource->source);
341 g_source_unref(&
d->timerSource->source);
342 d->timerSource =
nullptr;
343 g_source_destroy(&
d->idleTimerSource->source);
344 g_source_unref(&
d->idleTimerSource->source);
345 d->idleTimerSource =
nullptr;
348 for (
int i = 0;
i <
d->socketNotifierSource->pollfds.size(); ++
i) {
350 g_source_remove_poll(&
d->socketNotifierSource->source, &
p->pollfd);
354 g_source_destroy(&
d->socketNotifierSource->source);
355 g_source_unref(&
d->socketNotifierSource->source);
356 d->socketNotifierSource =
nullptr;
359 g_source_destroy(&
d->postEventSource->source);
360 g_source_unref(&
d->postEventSource->source);
361 d->postEventSource =
nullptr;
364#if GLIB_CHECK_VERSION (2, 22, 0)
365 g_main_context_pop_thread_default (
d->mainContext);
367 g_main_context_unref(
d->mainContext);
368 d->mainContext =
nullptr;
382 QEventLoop::ProcessEventsFlags savedFlags =
d->timerSource->processEventsFlags;
383 d->timerSource->processEventsFlags =
flags;
387 d->timerSource->runWithIdlePriority =
false;
390 bool result = g_main_context_iteration(
d->mainContext, canWait);
391 while (!
result && canWait)
392 result = g_main_context_iteration(
d->mainContext, canWait);
394 d->timerSource->processEventsFlags = savedFlags;
405 int sockfd = int(
notifier->socket());
409 qWarning(
"QSocketNotifier: Internal error");
413 qWarning(
"QSocketNotifier: socket notifiers cannot be enabled from another thread");
425 p->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
428 p->pollfd.events = G_IO_OUT | G_IO_ERR;
431 p->pollfd.events = G_IO_PRI | G_IO_ERR;
436 d->socketNotifierSource->pollfds.append(
p);
438 g_source_add_poll(&
d->socketNotifierSource->source, &
p->pollfd);
446 qWarning(
"QSocketNotifier: Internal error");
450 qWarning(
"QSocketNotifier: socket notifiers cannot be disabled from another thread");
457 for (
int i = 0;
i <
d->socketNotifierSource->pollfds.size(); ++
i) {
461 g_source_remove_poll(&
d->socketNotifierSource->source, &
p->pollfd);
463 d->socketNotifierSource->pollfds.removeAt(
i);
467 if (i <= d->socketNotifierSource->activeNotifierPos)
468 --
d->socketNotifierSource->activeNotifierPos;
478 if (timerId < 1 || interval < 0 || !
object) {
479 qWarning(
"QEventDispatcherGlib::registerTimer: invalid arguments");
482 qWarning(
"QEventDispatcherGlib::registerTimer: timers cannot be started from another thread");
488 d->timerSource->timerList.registerTimer(timerId, std::chrono::milliseconds{ interval },
496 qWarning(
"QEventDispatcherGlib::unregisterTimer: invalid argument");
499 qWarning(
"QEventDispatcherGlib::unregisterTimer: timers cannot be stopped from another thread");
505 return d->timerSource->timerList.unregisterTimer(timerId);
512 qWarning(
"QEventDispatcherGlib::unregisterTimers: invalid argument");
515 qWarning(
"QEventDispatcherGlib::unregisterTimers: timers cannot be stopped from another thread");
521 return d->timerSource->timerList.unregisterTimers(
object);
527 qWarning(
"QEventDispatcherUNIX:registeredTimers: invalid argument");
532 return d->timerSource->timerList.registeredTimers(
object);
539 qWarning(
"QEventDispatcherGlib::remainingTimeTime: invalid argument");
545 return d->timerSource->timerList.timerRemainingTime(timerId);
556 d->postEventSource->serialNumber.ref();
557 g_main_context_wakeup(
d->mainContext);
562#if !defined(GLIB_MAJOR_VERSION) || !defined(GLIB_MINOR_VERSION) || !defined(GLIB_MICRO_VERSION)
565 return ((GLIB_MAJOR_VERSION << 16) + (GLIB_MINOR_VERSION << 8) + GLIB_MICRO_VERSION) >= 0x020301;
576#include "moc_qeventdispatcher_glib_p.cpp"
DarwinBluetooth::LECBManagerNotifier * notifier
void aboutToBlock()
This signal is emitted before the event loop calls a function that could block.
void awake()
This signal is emitted after the event loop returns from a function that could block.
void storeRelaxed(T newValue) noexcept
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
static void sendPostedEvents(QObject *receiver=nullptr, int event_type=0)
Immediately dispatches all events which have been previously queued with QCoreApplication::postEvent(...
GSocketNotifierSource * socketNotifierSource
QEventDispatcherGlibPrivate(GMainContext *context=nullptr)
GPostEventSource * postEventSource
GTimerSource * timerSource
void runTimersOnceWithNormalPriority()
GIdleTimerSource * idleTimerSource
GMainContext * mainContext
void unregisterSocketNotifier(QSocketNotifier *socketNotifier) final
Unregisters notifier from the event dispatcher.
void wakeUp() final
\threadsafe
bool unregisterTimers(QObject *object) final
Unregisters all the timers associated with the given object.
void registerSocketNotifier(QSocketNotifier *socketNotifier) final
Registers notifier with the event loop.
static bool versionSupported()
void registerTimer(int timerId, qint64 interval, Qt::TimerType timerType, QObject *object) final
Register a timer with the specified timerId, interval, and timerType for the given object.
bool processEvents(QEventLoop::ProcessEventsFlags flags) override
Processes pending events that match flags until there are no more events to process.
QList< TimerInfo > registeredTimers(QObject *object) const final
Returns a list of registered timers for object.
QEventDispatcherGlib(QObject *parent=nullptr)
bool unregisterTimer(int timerId) final
Unregisters the timer with the given timerId.
int remainingTime(int timerId) final
Returns the remaining time in milliseconds with the given timerId.
void interrupt() final
Interrupts event dispatching.
QThread * thread() const
Returns the thread in which the object lives.
static Q_AUTOTEST_EXPORT QThreadData * current(bool createIfNecessary=true)
static QThread * currentThread()
static gboolean timerSourcePrepareHelper(GTimerSource *src, gint *timeout)
static gboolean postEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
static gboolean timerSourceCheck(GSource *source)
static gboolean idleTimerSourcePrepare(GSource *source, gint *timeout)
static gboolean socketNotifierSourcePrepare(GSource *, gint *timeout)
static gboolean idleTimerSourceDispatch(GSource *source, GSourceFunc, gpointer)
static gboolean postEventSourcePrepare(GSource *s, gint *timeout)
static Q_CONSTINIT GSourceFuncs postEventSourceFuncs
static gboolean idleTimerSourceCheck(GSource *source)
static gboolean timerSourceCheckHelper(GTimerSource *src)
static gboolean socketNotifierSourceCheck(GSource *source)
static gboolean postEventSourceCheck(GSource *source)
static gboolean socketNotifierSourceDispatch(GSource *source, GSourceFunc, gpointer)
static gboolean timerSourcePrepare(GSource *source, gint *timeout)
static gboolean timerSourceDispatch(GSource *source, GSourceFunc, gpointer)
static Q_CONSTINIT GSourceFuncs timerSourceFuncs
static Q_CONSTINIT GSourceFuncs socketNotifierSourceFuncs
static Q_CONSTINIT GSourceFuncs idleTimerSourceFuncs
struct _GMainContext GMainContext
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage return DBusPendingCall * pending
GLbitfield GLuint64 timeout
[4]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLsizei GLchar * source
Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) noexcept
QApplication app(argc, argv)
[0]
GTimerSource * timerSource
QSocketNotifier * socketNotifier
QEventDispatcherGlibPrivate * d
QList< GPollFDWithQSocketNotifier * > pollfds
QEventLoop::ProcessEventsFlags processEventsFlags
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent