title: QTcpSocket gets NULL after QTcpServer::nextPendingConnection()
body: <p>So I have a QTcpServer here (simplified version of Qt's Fortune Server Example). It was working fine earlier. Then I moved some things around and changed some code. Now my server crashes on start. As far as I can tell, after</p>
  
  <pre><code>tcpSocket = tcpServer-&gt;nextPendingConnection();
  </code></pre>
  
  <p>tcpSocket remains <strong>NULL</strong>. Thus all calls like <strong>tcpSocket->anyCall()</strong> will cause a seg fault. Application output shows:</p>
  
  <pre><code>QObject::connect: invalid null parameter
  </code></pre>
  
  <p>So my question is, why is tcpServer->nextPendingConnection() returning <strong>NULL</strong>
   all of a sudden, when before I moved things around it worked just fine?</p>
  
  <p>Here are the relevant parts of my code:</p>
  
  <pre><code>#include &lt;QtWidgets&gt;
  #include &lt;QtNetwork&gt;
  #include "server.h"
  
  Server::Server(QWidget *parent)
  : QDialog(parent), statusLabel(new QLabel), tcpServer(Q_NULLPTR), tcpSocket(Q_NULLPTR), networkSession(0), blockSize(0), userAuthenticated(false)
  {
      QNetworkConfigurationManager manager;
      QNetworkConfiguration config = manager.defaultConfiguration();
      networkSession = new QNetworkSession(config, this);
      sessionOpened();
  
      ...
      // GUI stuff here //
      ...
  
      this-&gt;read_newClient();
  }
  
  void Server::sessionOpened()
  {
      tcpServer = new QTcpServer(this);
  
      // some if else checks here //
  
      tcpSocket = tcpServer-&gt;nextPendingConnection(); // problem here //
      connect(tcpSocket, &amp;QAbstractSocket::disconnected, tcpSocket, &amp;QObject::deleteLater); // line that crashes //
  }
  
  void Server::read_newClient()
  {
      QString data;
      if (!clientSocket-&gt;waitForReadyRead())
      {
          qDebug() &lt;&lt; "Cannot read";
          return;
      }
      data = readData();
  }
  </code></pre>