summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2011-04-14 12:08:23 (GMT)
committerKai Koehne <kai.koehne@nokia.com>2011-04-14 12:41:37 (GMT)
commitddd633f2f4234aae353cd0239974a3a997abc71e (patch)
tree5b9d887ae402884fe5e0584d238d727a73df9d4a
parenteac733e658422af2ceefea294023d89fc6512143 (diff)
downloadQt-ddd633f2f4234aae353cd0239974a3a997abc71e.zip
Qt-ddd633f2f4234aae353cd0239974a3a997abc71e.tar.gz
Qt-ddd633f2f4234aae353cd0239974a3a997abc71e.tar.bz2
QDeclarativeDebug: Don't crash when connection is closed
Protocol might still be in the process of processing messages when disconnect() is called (e.g. due to an invalid package). Therefore delay it's deletion until the next event loop runs. Reviewed-by: Christiaan Janssen Task-number: QTBUG-18771
-rw-r--r--src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp
index 69c1ef5..7db0db3 100644
--- a/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp
+++ b/src/plugins/qmltooling/tcpserver/qtcpserverconnection.cpp
@@ -97,7 +97,8 @@ void QTcpServerConnection::send(const QByteArray &message)
{
Q_D(QTcpServerConnection);
- if (!isConnected())
+ if (!isConnected()
+ || !d->protocol || !d->socket)
return;
QPacket pack;
@@ -111,9 +112,10 @@ void QTcpServerConnection::disconnect()
{
Q_D(QTcpServerConnection);
- delete d->protocol;
+ // protocol might still be processing packages at this point
+ d->protocol->deleteLater();
d->protocol = 0;
- delete d->socket;
+ d->socket->deleteLater();
d->socket = 0;
}
@@ -143,6 +145,9 @@ void QTcpServerConnection::listen()
void QTcpServerConnection::readyRead()
{
Q_D(QTcpServerConnection);
+ if (!d->protocol)
+ return;
+
QPacket packet = d->protocol->read();
QByteArray content = packet.data();