diff options
author | Bernd Weimer <bweimer@blackberry.com> | 2013-04-05 08:36:32 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-08 09:19:40 (GMT) |
commit | 7e40da452773e104ce3fccb8d9f033ab2e01a8a4 (patch) | |
tree | 8c92f36e440b0c91035b210666e0810f23ba46b9 /src | |
parent | b870caf6d29d493c7dbe1d5cb8e255d8648a55e6 (diff) | |
download | Qt-7e40da452773e104ce3fccb8d9f033ab2e01a8a4.zip Qt-7e40da452773e104ce3fccb8d9f033ab2e01a8a4.tar.gz Qt-7e40da452773e104ce3fccb8d9f033ab2e01a8a4.tar.bz2 |
Avoid socket notifiers on invalid file descriptors
There is potential trouble and no point in registering a QSocketNotifier
on an invalid file descriptor. This is prevented now in addition to the
existing warning.
Backported from qt5/qtbase: d20851f8ecd044479dd1892e92937a9135aa7856
Change-Id: I86e0a2c7ebdc6fb4cffcd39958003506ff01cb46
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qsocketnotifier.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp index 97cfd34..2f2dec8 100644 --- a/src/corelib/kernel/qsocketnotifier.cpp +++ b/src/corelib/kernel/qsocketnotifier.cpp @@ -171,18 +171,17 @@ QT_BEGIN_NAMESPACE QSocketNotifier::QSocketNotifier(int socket, Type type, QObject *parent) : QObject(parent) { - if (socket < 0) - qWarning("QSocketNotifier: Invalid socket specified"); sockfd = socket; sntype = type; snenabled = true; Q_D(QObject); - if (!d->threadData->eventDispatcher) { + if (socket < 0) + qWarning("QSocketNotifier: Invalid socket specified"); + else if (!d->threadData->eventDispatcher) qWarning("QSocketNotifier: Can only be used with threads started with QThread"); - } else { + else d->threadData->eventDispatcher->registerSocketNotifier(this); - } } #ifdef QT3_SUPPORT |