summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h4
-rw-r--r--src/corelib/kernel/qcfsocketnotifier.cpp13
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp6
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp52
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h3
-rw-r--r--src/corelib/kernel/qobject.cpp7
6 files changed, 61 insertions, 24 deletions
diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h
index a256b03523..0d3e53e4a7 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.h
+++ b/src/corelib/kernel/qabstracteventdispatcher.h
@@ -102,9 +102,7 @@ public:
virtual void wakeUp() = 0;
virtual void interrupt() = 0;
-#if QT_DEPRECATED_SINCE(5, 9)
- QT_DEPRECATED virtual void flush() = 0;
-#endif
+ virtual void flush() = 0; // ### Qt6: remove, mark final or make protected
virtual void startingUp();
virtual void closingDown();
diff --git a/src/corelib/kernel/qcfsocketnotifier.cpp b/src/corelib/kernel/qcfsocketnotifier.cpp
index a079031e96..1fee2aa5fc 100644
--- a/src/corelib/kernel/qcfsocketnotifier.cpp
+++ b/src/corelib/kernel/qcfsocketnotifier.cpp
@@ -292,10 +292,19 @@ void QCFSocketNotifier::enableSocketNotifiers(CFRunLoopObserverRef ref, CFRunLoo
continue;
}
- if (!socketInfo->readNotifier)
+ // Apple docs say: "If a callback is automatically re-enabled,
+ // it is called every time the condition becomes true ... If a
+ // callback is not automatically re-enabled, then it gets called
+ // exactly once, and is not called again until you manually
+ // re-enable that callback by calling CFSocketEnableCallBacks()".
+ // So, we don't need to enable callbacks on registering.
+ socketInfo->readEnabled = (socketInfo->readNotifier != nullptr);
+ if (!socketInfo->readEnabled)
CFSocketDisableCallBacks(socketInfo->socket, kCFSocketReadCallBack);
- if (!socketInfo->writeNotifier)
+ socketInfo->writeEnabled = (socketInfo->writeNotifier != nullptr);
+ if (!socketInfo->writeEnabled)
CFSocketDisableCallBacks(socketInfo->socket, kCFSocketWriteCallBack);
+ continue;
}
if (socketInfo->readNotifier && !socketInfo->readEnabled) {
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 4a4ad3ddf8..0104ba0101 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -714,12 +714,14 @@ QCoreApplication::QCoreApplication(QCoreApplicationPrivate &p)
\sa sendPostedEvents(), processEvents(), QAbstractEventDispatcher::flush()
*/
+#if QT_DEPRECATED_SINCE(5, 9)
void QCoreApplication::flush()
{
if (self && self->d_func()->eventDispatcher)
self->d_func()->eventDispatcher->flush();
}
#endif
+#endif
/*!
Constructs a Qt core application. Core applications are applications without
@@ -756,6 +758,10 @@ QCoreApplication::QCoreApplication(int &argc, char **argv
void QCoreApplicationPrivate::init()
{
+#if defined(Q_OS_MACOS)
+ QMacAutoReleasePool pool;
+#endif
+
Q_Q(QCoreApplication);
initLocale();
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 74fa2d8d50..40db5020ab 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -177,15 +177,24 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
QSNDict *dict = sn_vec[type];
QSockNot *sn = dict ? dict->value(wp) : 0;
- if (sn) {
- d->doWsaAsyncSelect(sn->fd, 0);
- d->active_fd[sn->fd].selected = false;
+ if (sn == nullptr) {
d->postActivateSocketNotifiers();
- if (type < 3) {
- QEvent event(QEvent::SockAct);
- QCoreApplication::sendEvent(sn->obj, &event);
- } else {
- QEvent event(QEvent::SockClose);
+ } else {
+ Q_ASSERT(d->active_fd.contains(sn->fd));
+ QSockFd &sd = d->active_fd[sn->fd];
+ if (sd.selected) {
+ Q_ASSERT(sd.mask == 0);
+ d->doWsaAsyncSelect(sn->fd, 0);
+ sd.selected = false;
+ }
+ d->postActivateSocketNotifiers();
+
+ // Ignore the message if a notification with the same type was
+ // received previously. Suppressed message is definitely spurious.
+ const long eventCode = WSAGETSELECTEVENT(lp);
+ if ((sd.mask & eventCode) != eventCode) {
+ sd.mask |= eventCode;
+ QEvent event(type < 3 ? QEvent::SockAct : QEvent::SockClose);
QCoreApplication::sendEvent(sn->obj, &event);
}
}
@@ -194,13 +203,22 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
} else if (message == WM_QT_ACTIVATENOTIFIERS) {
Q_ASSERT(d != 0);
- // register all socket notifiers
- for (QSFDict::iterator it = d->active_fd.begin(), end = d->active_fd.end();
- it != end; ++it) {
- QSockFd &sd = it.value();
- if (!sd.selected) {
- d->doWsaAsyncSelect(it.key(), sd.event);
- sd.selected = true;
+ // Postpone activation if we have unhandled socket notifier messages
+ // in the queue. WM_QT_ACTIVATENOTIFIERS will be posted again as a result of
+ // event processing.
+ MSG msg;
+ if (!PeekMessage(&msg, 0, WM_QT_SOCKETNOTIFIER, WM_QT_SOCKETNOTIFIER, PM_NOREMOVE)
+ && d->queuedSocketEvents.isEmpty()) {
+ // register all socket notifiers
+ for (QSFDict::iterator it = d->active_fd.begin(), end = d->active_fd.end();
+ it != end; ++it) {
+ QSockFd &sd = it.value();
+ if (!sd.selected) {
+ d->doWsaAsyncSelect(it.key(), sd.event);
+ // allow any event to be accepted
+ sd.mask = 0;
+ sd.selected = true;
+ }
}
}
d->activateNotifiersPosted = false;
@@ -706,7 +724,9 @@ void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier)
}
sd.event |= event;
} else {
- d->active_fd.insert(sockfd, QSockFd(event));
+ // Disable the events which could be implicitly re-enabled. Next activation
+ // of socket notifiers will reset the mask.
+ d->active_fd.insert(sockfd, QSockFd(event, FD_READ | FD_ACCEPT | FD_WRITE | FD_OOB));
}
d->postActivateSocketNotifiers();
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index 423dc5b169..f6d1bffdf5 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -126,9 +126,10 @@ typedef QHash<int, QSockNot *> QSNDict;
struct QSockFd {
long event;
+ long mask;
bool selected;
- explicit inline QSockFd(long ev = 0) : event(ev), selected(false) { }
+ explicit inline QSockFd(long ev = 0, long ma = 0) : event(ev), mask(ma), selected(false) { }
};
typedef QHash<int, QSockFd> QSFDict;
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 1b05962c07..3f50716cd7 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4292,7 +4292,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
This macro registers an enum type with the meta-object system.
It must be placed after the enum declaration in a class that has the Q_OBJECT or the
- Q_GADGET macro. For namespaces use \l Q_ENUM_NS instead.
+ Q_GADGET macro. For namespaces use \l Q_ENUM_NS() instead.
For example:
@@ -4319,7 +4319,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
This macro registers a single \l{QFlags}{flags type} with the
meta-object system. It is typically used in a class definition to declare
that values of a given enum can be used as flags and combined using the
- bitwise OR operator. For namespaces use \l Q_FLAG_NS instead.
+ bitwise OR operator. For namespaces use \l Q_FLAG_NS() instead.
The macro must be placed after the enum declaration.
@@ -4340,6 +4340,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
/*!
\macro Q_ENUM_NS(...)
+ \relates QObject
\since 5.8
This macro registers an enum type with the meta-object system.
@@ -4363,6 +4364,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
/*!
\macro Q_FLAG_NS(...)
+ \relates QObject
\since 5.8
This macro registers a single \l{QFlags}{flags type} with the
@@ -5079,4 +5081,5 @@ bool QMetaObject::Connection::isConnected_helper() const
QT_END_NAMESPACE
+#include "moc_qnamespace.cpp"
#include "moc_qobject.cpp"