Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-16994

QNetworkSession::waitForOpened returns false when bearer is already active

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2: Important P2: Important
    • 4.7.3
    • 4.7.1
    • Network: Sockets
    • None
    • symbian3, Nokia N8
    • d238b0ba

      Precondition:
      Default connection is already activated (on the N8, the network seems to be started automatically before initTestCase() but on the 5800 it isn't)

      Test code:

      #ifndef QT_NO_BEARERMANAGEMENT
          netConfMan = new QNetworkConfigurationManager(this);
          networkConfiguration = netConfMan->defaultConfiguration();
          networkSession.reset(new QNetworkSession(networkConfiguration));
          if (!networkSession->isOpen()) {
              networkSession->open();
              bool ok = networkSession->waitForOpened(30000);
              qDebug() << networkSession->isOpen() << networkSession->error() << networkSession->errorString();
              QVERIFY(ok);
          }
      #endif
      

      Fix:

      diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
      index eac0456..41a8854 100644
      --- a/src/network/bearer/qnetworksession.cpp
      +++ b/src/network/bearer/qnetworksession.cpp
      @@ -310,7 +310,7 @@ bool QNetworkSession::waitForOpened(int msecs)
           if (d->isOpen)
               return true;
       
      -    if (d->state != Connecting)
      +    if (d->state != Connecting && d->state != Connected) //state is connected when opening an already active interface
               return false;
       
           QEventLoop loop;
      
      

      Root Cause:

      In the symbian implementation of void QNetworkSessionPrivateImpl::open(), there is this code:

              // Avoid flip flop of states if the configuration is already
              // active. IsOpen/opened() will indicate when ready.
              if (state != QNetworkSession::Connected) {
                  newState(QNetworkSession::Connecting);
              }
      
      

      Which means that if syncStateWithInterface called from the constructor detected the connection is already active then the session is in connected state before open is called.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            shkearns Shane Kearns
            shkearns Shane Kearns
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes