diff options
author | Bernd Weimer <bweimer@blackberry.com> | 2013-11-05 10:04:51 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-06 08:29:33 (GMT) |
commit | cab363afa347e22c5f738f15533489e0cd671d59 (patch) | |
tree | 8b16ea85662e7d13937980099d8d44034cc754a1 | |
parent | 427e398a7b7f3345fb4dcbc275b3ea29f211851b (diff) | |
download | Qt-cab363afa347e22c5f738f15533489e0cd671d59.zip Qt-cab363afa347e22c5f738f15533489e0cd671d59.tar.gz Qt-cab363afa347e22c5f738f15533489e0cd671d59.tar.bz2 |
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.
Back-port of qtbase/e9c51a1fdc9092e5589fd6f823ad0e704e293c88
Task-number: QTBUG-34536
Change-Id: I767a15cb2883bc820da5c858613ffb26abc002e4
Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Reviewed-by: Petr NejedlĂ˝ <pnejedly@blackberry.com>
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_blackberry.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp index 0119ee7..b788fa2 100644 --- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp +++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp @@ -236,9 +236,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); @@ -264,6 +261,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) @@ -279,23 +279,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 timevalToMillisecs(const timeval &tv) |