mirror of
https://github.com/itay-grudev/SingleApplication.git
synced 2024-11-15 12:15:43 +08:00
Fix crash when sending ack on removed connection
The emit might interrupt our function and causes us to return to the event loop. In that time frame the other and might close the connection, causing our connection to be removed. In that case we call writeAck on a dangling pointer, in the best case causing a crash. So lets finish our business before emitting our signal. fixes #138
This commit is contained in:
parent
0d7b2630bd
commit
3650975e56
@ -503,12 +503,14 @@ void SingleApplicationPrivate::slotDataAvailable( QLocalSocket *dataSocket, quin
|
||||
if ( !isFrameComplete( dataSocket ) )
|
||||
return;
|
||||
|
||||
Q_EMIT q->receivedMessage( instanceId, dataSocket->readAll() );
|
||||
const QByteArray message = dataSocket->readAll();
|
||||
|
||||
writeAck( dataSocket );
|
||||
|
||||
ConnectionInfo &info = connectionMap[dataSocket];
|
||||
info.stage = StageConnectedHeader;
|
||||
|
||||
Q_EMIT q->receivedMessage( instanceId, message);
|
||||
}
|
||||
|
||||
void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedSocket, quint32 instanceId )
|
||||
|
Loading…
Reference in New Issue
Block a user