--- a/src/QuailEventLoop.cpp Mon Sep 23 16:03:31 2013 +0100
+++ b/src/QuailEventLoop.cpp Mon Sep 23 16:31:00 2013 +0100
@@ -143,11 +143,7 @@
info->timer = new QQuailTimer(info->handle, func, data);
//info->timer->moveToThread(quailThread);
m_sources.insert(info->handle, info);
- info->timer->start(interval);
+ info->timer->start(interval); --- a/src/QuailWinGlibEventLoop.cpp Mon Sep 23 16:03:31 2013 +0100
+++ b/src/QuailWinGlibEventLoop.cpp Mon Sep 23 16:31:00 2013 +0100
@@ -13,7 +13,8 @@
#include "quailtimerinfolist.h"
+#define WM_SOCKET (WM_USER + 1) struct GPollFDWithQSocketNotifier
@@ -269,11 +270,7 @@
-# define QS_RAWINPUT 0x0000
# define QS_RAWINPUT 0x0400
@@ -294,197 +291,6 @@
SendPostedEventsWindowsTimerId = ~1u
-QT_BEGIN_INCLUDE_NAMESPACE
-QT_END_INCLUDE_NAMESPACE
-// Asynchronous Winsocks ------------------------------------------
-QT_BEGIN_INCLUDE_NAMESPACE
-QT_END_INCLUDE_NAMESPACE
-//#define QCE_ASYNC_DEBUG
- class SocketAsyncHandler;
- class SocketAsyncHandler : public QThread
- void select(SOCKET sock, HWND handle, unsigned int msg, long ev);
- void removeSelect(SOCKET sock);
- void safeRemove(SOCKET sock);
- QMap<SOCKET, SockInfo> sockets;
- SocketAsyncHandler::SocketAsyncHandler()
- SocketAsyncHandler::~SocketAsyncHandler()
- while (sockets.size() > 0)
- removeSelect(sockets.begin().key());
- void SocketAsyncHandler::removeSelect(SOCKET sock)
- if (!sockets.contains(sock))
- void SocketAsyncHandler::safeRemove(SOCKET sock)
- QMutexLocker locker(&mutex);
- void SocketAsyncHandler::select(SOCKET sock, HWND handle, unsigned int msg, long ev)
- QMutexLocker locker(&mutex);
- if (sockets.contains(sock))
- sockets.insert(sock, info);
- void SocketAsyncHandler::run()
- while (!supposedToDie && sockets.isEmpty()) {
- // Copy current items to reduce lock time
- // and to be able to use SendMessage
- QMap<SOCKET, SockInfo> currentSockets = sockets;
- fd_set readS, writeS, exS;
- for (QMap<SOCKET, SockInfo>::iterator it = currentSockets.begin(); it != currentSockets.end(); ++it) {
- const SockInfo &info = it.value();
- maxFd = qMax(maxFd, socket);
- if ((info.ev & FD_READ) || (info.ev & FD_CLOSE) || (info.ev & FD_ACCEPT))
- FD_SET(socket, &readS);
- if ((info.ev & FD_WRITE)|| (info.ev & FD_CONNECT))
- FD_SET(socket, &writeS);
- timeout.tv_usec = 50000;
- int result = ::select(maxFd + 1, &readS, &writeS, &exS, &timeout);
- for (QMap<SOCKET, SockInfo>::const_iterator it = currentSockets.constBegin();
- it != currentSockets.constEnd(); ++it) {
- if (FD_ISSET(sock, &readS))
- ret = SendMessage(handle, tmpMsg, sock, FD_READ);
- if (FD_ISSET(sock, &writeS))
- ret = SendMessage(handle, tmpMsg, sock, FD_WRITE);
- if (FD_ISSET(sock, &exS))
- ret = SendMessage(handle, tmpMsg, sock, FD_OOB);
- else if (result == 0) { //timeout
- qDebug(" WSAAsync select timeout");
- } else if (result < 0) { // SocketError
- // This might happen because of two reasons
- // 1. We already closed a socket in between the copy and the select
- // and thus select() returns an error
- // 2. Something is really wrong, then
- // ### Loop on all descriptors, try to select and remove the
- qWarning("WSAAsync select error %d", WSAGetLastError());
-Q_GLOBAL_STATIC(SocketAsyncHandler, qt_async_handler)
-int WSAAsyncSelect(SOCKET sock, HWND handle, unsigned int msg, long ev)
- qDebug() << "QuailEventDispatcherWinGlib::WSAAsyncSelect";
- if (sock == 0 || handle == 0 || handle == INVALID_HANDLE_VALUE) {
- WSASetLastError(WSAEINVAL);
- if (msg == 0 && ev == 0)
- qt_async_handler()->safeRemove(sock);
- qt_async_handler()->select(sock, handle, msg, ev);
- qt_async_handler()->start(QThread::LowPriority);
-int WSAAsyncSelect(SOCKET, HWND, unsigned int, long)
#if !defined(DWORD_PTR) && !defined(Q_OS_WIN64)
@@ -510,7 +316,6 @@
-#if !defined(Q_OS_WINCE)
# if defined(_MSC_VER) && _MSC_VER >= 1700
if (QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS8) {
@@ -519,11 +324,8 @@
qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent");
qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent");
- qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeKillEvent");
+ qDebug() << "QuailEventDispatcherWinGlib::resolveTimerAPI.end"; QuailEventDispatcherWinGlib::QuailEventDispatcherWinGlib(QObject *parent)
@@ -591,7 +393,7 @@
g_source_set_can_recurse(&idleTimerSource->source, true);
g_source_set_priority(&idleTimerSource->source, G_PRIORITY_DEFAULT_IDLE);
g_source_attach(&idleTimerSource->source, mainContext);
+ qDebug() << "QuailEventDispatcherWinGlib.end"; void QuailEventDispatcherWinGlib::runTimersOnceWithNormalPriority()
@@ -747,15 +549,12 @@
return CallNextHookEx(0, code, wp, lp);
static HWND qt_create_internal_window(const QuailEventDispatcherWinGlib *eventDispatcher)
+ qDebug() << "qt_create_internal_window"; // make sure that multiple Qt's can coexist in the same process
QString className = QLatin1String("QuailEventDispatcherWinGlib_Internal_Widget") + QString::number(quintptr(qt_internal_proc));
@@ -772,11 +571,7 @@
wc.lpszClassName = reinterpret_cast<const wchar_t *> (className.utf16());
HWND parent = HWND_MESSAGE;
HWND wnd = CreateWindow(wc.lpszClassName, // classname
wc.lpszClassName, // window name
@@ -795,7 +590,7 @@
SetWindowLong(wnd, GWL_USERDATA, (LONG)eventDispatcher);
+ qDebug() << "qt_create_internal_window.end"; @@ -877,7 +672,7 @@
// BoundsChecker may emit a warning for WSAAsyncSelect when sn_event == 0
// This is a BoundsChecker bug and not a Qt bug
- //WSAAsyncSelect(socket, internalHwnd, sn_event ? int(WM_QT_SOCKETNOTIFIER) : 0, sn_event);
+ WSAAsyncSelect(socket, internalHwnd, sn_event ? int(WM_QT_SOCKETNOTIFIER) : 0, sn_event); void QuailEventDispatcherWinGlib::createInternalHwnd()
@@ -890,13 +685,11 @@
d->internalHwnd = qt_create_internal_window(this);
// setup GetMessage hook needed to drive our posted events
d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId());
if (!d->getMessageHook) {
qFatal("Qt: INTERNALL ERROR: failed to install GetMessage hook");
// register all socket notifiers
QList<int> sockets = (d->sn_read.keys().toSet()
@@ -985,11 +778,6 @@
- // WinCE doesn't support hooks at all, so we have to call this by hand :(
- (void) qt_GetMessageHook(0, PM_REMOVE, (LPARAM) &msg);
if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) {
if (seenWM_QT_SENDPOSTEDEVENTS) {
// when calling processEvents() "manually", we only want to send posted
@@ -1286,13 +1074,8 @@
QuailEventDispatcherWinGlib *d = this;
//### this could break if events are removed/added in the activation
for (int i=0; i<d->winEventNotifierList.count(); i++) {
-#if !defined(Q_OS_WINCE)
if (WaitForSingleObjectEx(d->winEventNotifierList.at(i)->handle(), 0, TRUE) == WAIT_OBJECT_0)
d->activateEventNotifier(d->winEventNotifierList.at(i));
- if (WaitForSingleObject(d->winEventNotifierList.at(i)->handle(), 0) == WAIT_OBJECT_0)
- d->activateEventNotifier(d->winEventNotifierList.at(i));
@@ -1373,11 +1156,9 @@
UnhookWindowsHookEx(d->getMessageHook);
bool QuailEventDispatcherWinGlib::event(QEvent *e)