summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Weimer <bweimer@blackberry.com>2013-11-04 11:49:56 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-05 09:13:09 +0100
commite9c51a1fdc9092e5589fd6f823ad0e704e293c88 (patch)
tree5cb6374950e2bc1f3e84d0e250d747273ee266bc
parent215e525a5cefe18bd8885b56d12ea35eb2cd3b98 (diff)
BlackBerry: Prevent superfluous removal of socket notifiers
File descriptors have always been removed from bps before adding them, which lead to an annoying warning. "QEventDispatcherUNIX::registerSocketNotifier()" needs to be called after "ioEvents()" to prevent this. Task-number: QTBUG-34536 Change-Id: If074ff7a6638fe234abc100c81d094e182de7537 Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com> Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
-rw-r--r--src/corelib/kernel/qeventdispatcher_blackberry.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp
index b9137ec139..a52cc60eaa 100644
--- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp
+++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp
@@ -237,9 +237,6 @@ void QEventDispatcherBlackberry::registerSocketNotifier(QSocketNotifier *notifie
return;
}
- // Call the base Unix implementation. Needed to allow select() to be called correctly
- QEventDispatcherUNIX::registerSocketNotifier(notifier);
-
// Register the fd with bps
BpsChannelScopeSwitcher channelSwitcher(d->bps_channel);
int io_events = ioEvents(sockfd);
@@ -265,6 +262,9 @@ void QEventDispatcherBlackberry::registerSocketNotifier(QSocketNotifier *notifie
const int result = bps_add_fd(sockfd, io_events, &bpsIOHandler, d->ioData.data());
if (Q_UNLIKELY(result != BPS_SUCCESS))
qWarning() << "QEventDispatcherBlackberry: bps_add_fd failed";
+
+ // Call the base Unix implementation. Needed to allow select() to be called correctly
+ QEventDispatcherUNIX::registerSocketNotifier(notifier);
}
void QEventDispatcherBlackberry::unregisterSocketNotifier(QSocketNotifier *notifier)
@@ -280,23 +280,22 @@ void QEventDispatcherBlackberry::unregisterSocketNotifier(QSocketNotifier *notif
return;
}
- // Allow the base Unix implementation to unregister the fd too
+ // Allow the base Unix implementation to unregister the fd too (before call to ioEvents()!)
QEventDispatcherUNIX::unregisterSocketNotifier(notifier);
// Unregister the fd with bps
BpsChannelScopeSwitcher channelSwitcher(d->bps_channel);
- const int io_events = ioEvents(sockfd);
int result = bps_remove_fd(sockfd);
if (Q_UNLIKELY(result != BPS_SUCCESS))
qWarning() << "QEventDispatcherBlackberry: bps_remove_fd failed" << sockfd;
- // if no other socket notifier is watching sockfd, our job ends here
- if (!io_events)
- return;
-
- result = bps_add_fd(sockfd, io_events, &bpsIOHandler, d->ioData.data());
- if (Q_UNLIKELY(result != BPS_SUCCESS))
- qWarning("QEventDispatcherBlackberry: bps_add_fd error");
+ const int io_events = ioEvents(sockfd);
+ // if other socket notifier is watching sockfd, readd it
+ if (io_events) {
+ result = bps_add_fd(sockfd, io_events, &bpsIOHandler, d->ioData.data());
+ if (Q_UNLIKELY(result != BPS_SUCCESS))
+ qWarning("QEventDispatcherBlackberry: bps_add_fd error");
+ }
}
static inline int timespecToMillisecs(const timespec &tv)