Don't assume Q_OS_UNIX means we support QEventLoop::X11ExcludeTimers

A QCoreApplication may run a different event dispatcher, such as the
QEventDispatcherBlackberry, and QGuiApplications will have the GUI
dispatcher provided by the QPA plugin, such as QCocoaEventDispatcher.

Neither support X11ExcludeTimers.

Change-Id: Id5ea1c7dd74a127e13fa4d2eaa9a1bd2715a9dbb
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
Tor Arne Vestbø 2013-07-17 22:25:11 +02:00 committed by The Qt Project
parent efc43ae83d
commit 126c1b4b41
2 changed files with 19 additions and 3 deletions

View File

@ -6,3 +6,5 @@ SOURCES = tst_qeventloop.cpp
win32:!wince*:LIBS += -luser32
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
contains(QT_CONFIG, glib): DEFINES += HAVE_GLIB

View File

@ -46,6 +46,12 @@
#include <qcoreevent.h>
#include <qeventloop.h>
#include <private/qeventloop_p.h>
#if defined(Q_OS_UNIX)
#include <private/qeventdispatcher_unix_p.h>
#if defined(HAVE_GLIB)
#include <private/qeventdispatcher_glib_p.h>
#endif
#endif
#include <qmutex.h>
#include <qthread.h>
#include <qtimer.h>
@ -491,11 +497,19 @@ void tst_QEventLoop::processEventsExcludeTimers()
QCOMPARE(timerReceiver.gotTimerEvent, timerId);
timerReceiver.gotTimerEvent = -1;
// normal process events will send timers
// but not if we exclude timers
eventLoop.processEvents(QEventLoop::X11ExcludeTimers);
#if !defined(Q_OS_UNIX)
QEXPECT_FAIL("", "X11ExcludeTimers only works on UN*X", Continue);
QAbstractEventDispatcher *eventDispatcher = QCoreApplication::eventDispatcher();
#if defined(Q_OS_UNIX)
if (!qobject_cast<QEventDispatcherUNIX *>(eventDispatcher)
#if defined(HAVE_GLIB)
&& !qobject_cast<QEventDispatcherGlib *>(eventDispatcher)
#endif
)
#endif
QEXPECT_FAIL("", "X11ExcludeTimers only supported in the UNIX/Glib dispatchers", Continue);
QCOMPARE(timerReceiver.gotTimerEvent, -1);
timerReceiver.gotTimerEvent = -1;