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.

Change-Id: I6fc3c639b167ea98d09a2738986360cc4b3fc210
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Bernd Weimer 2013-04-02 16:54:29 +02:00 committed by The Qt Project
parent 01b4b7f917
commit d20851f8ec
1 changed files with 4 additions and 5 deletions

View File

@ -181,17 +181,16 @@ QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent)
: QObject(*new QSocketNotifierPrivate, parent)
{
Q_D(QSocketNotifier);
if (socket < 0)
qWarning("QSocketNotifier: Invalid socket specified");
d->sockfd = socket;
d->sntype = type;
d->snenabled = true;
if (!d->threadData->eventDispatcher.load()) {
if (socket < 0)
qWarning("QSocketNotifier: Invalid socket specified");
else if (!d->threadData->eventDispatcher.load())
qWarning("QSocketNotifier: Can only be used with threads started with QThread");
} else {
else
d->threadData->eventDispatcher.load()->registerSocketNotifier(this);
}
}
/*!