Skip to content

Commit e42c6d8

Browse files
author
Nehmulos
committed
NULL the m_tcpServer pointer when the data is destroyed;
1 parent cec0a97 commit e42c6d8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/qhttpserver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ bool QHttpServer::listen(const QHostAddress &address, quint16 port)
118118
bool couldBindToPort = m_tcpServer->listen(address, port);
119119
if (couldBindToPort) {
120120
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection()));
121+
connect(m_tcpServer, SIGNAL(destroyed()), this, SLOT(tcpServerDestoryed()));
121122
} else {
122123
delete m_tcpServer;
123124
m_tcpServer = NULL;
@@ -135,3 +136,7 @@ void QHttpServer::close()
135136
if (m_tcpServer)
136137
m_tcpServer->close();
137138
}
139+
140+
void QHttpServer::tcpServerDestoryed() {
141+
m_tcpServer = NULL;
142+
}

src/qhttpserver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class QHTTPSERVER_API QHttpServer : public QObject
8181

8282
/// Stop the server and listening for new connections.
8383
void close();
84-
8584
signals:
8685
/// Emitted when a client makes a new request to the server.
8786
/** The slot should use the given @c request and @c response
@@ -92,6 +91,7 @@ class QHTTPSERVER_API QHttpServer : public QObject
9291

9392
private slots:
9493
void newConnection();
94+
void tcpServerDestoryed();
9595

9696
private:
9797
QTcpServer *m_tcpServer;

0 commit comments

Comments
 (0)