diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2010-12-10 03:47:31 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-12-10 03:47:31 (GMT) |
commit | d509ec9707b3c4ce7efd7af27a18d171913c5682 (patch) | |
tree | afbb475f4200fc3e8601e36ebf8b4f7c42a19823 | |
parent | 8c79236781cc2dea904f36d6e8c751e6635b9bb9 (diff) | |
download | Qt-d509ec9707b3c4ce7efd7af27a18d171913c5682.zip Qt-d509ec9707b3c4ce7efd7af27a18d171913c5682.tar.gz Qt-d509ec9707b3c4ce7efd7af27a18d171913c5682.tar.bz2 |
simplify waitForOpened()
and don't exclude socket events so they might be used pings and so on...
Merge-request: 899
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
-rw-r--r-- | src/network/bearer/qnetworksession.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp index dedbbf9..eac0456 100644 --- a/src/network/bearer/qnetworksession.cpp +++ b/src/network/bearer/qnetworksession.cpp @@ -313,19 +313,16 @@ bool QNetworkSession::waitForOpened(int msecs) if (d->state != Connecting) return false; - QEventLoop* loop = new QEventLoop(this); - QObject::connect(d, SIGNAL(quitPendingWaitsForOpened()), - loop, SLOT(quit())); - QObject::connect(this, SIGNAL(error(QNetworkSession::SessionError)), - loop, SLOT(quit())); + QEventLoop loop; + QObject::connect(d, SIGNAL(quitPendingWaitsForOpened()), &loop, SLOT(quit())); + QObject::connect(this, SIGNAL(error(QNetworkSession::SessionError)), &loop, SLOT(quit())); //final call if (msecs >= 0) - QTimer::singleShot(msecs, loop, SLOT(quit())); + QTimer::singleShot(msecs, &loop, SLOT(quit())); - loop->exec(); - loop->disconnect(); - loop->deleteLater(); + // enter the event loop and wait for opened/error/timeout + loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents); return d->isOpen; } |