Fix signal-slot issues

This commit is contained in:
Jonas Kvinge 2021-03-26 00:16:25 +01:00
parent 4aeac8fa3e
commit 4052d37110

View File

@ -321,22 +321,22 @@ void SingleApplicationPrivate::slotConnectionEstablished()
QLocalSocket *nextConnSocket = server->nextPendingConnection();
connectionMap.insert(nextConnSocket, ConnectionInfo());
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose,
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose, this,
[nextConnSocket, this](){
auto &info = connectionMap[nextConnSocket];
Q_EMIT this->slotClientConnectionClosed( nextConnSocket, info.instanceId );
this->slotClientConnectionClosed( nextConnSocket, info.instanceId );
}
);
QObject::connect(nextConnSocket, &QLocalSocket::disconnected, nextConnSocket, &QLocalSocket::deleteLater);
QObject::connect(nextConnSocket, &QLocalSocket::destroyed,
QObject::connect(nextConnSocket, &QLocalSocket::destroyed, this,
[nextConnSocket, this](){
connectionMap.remove(nextConnSocket);
}
);
QObject::connect(nextConnSocket, &QLocalSocket::readyRead,
QObject::connect(nextConnSocket, &QLocalSocket::readyRead, this,
[nextConnSocket, this](){
auto &info = connectionMap[nextConnSocket];
switch(info.stage){
@ -347,7 +347,7 @@ void SingleApplicationPrivate::slotConnectionEstablished()
readInitMessageBody(nextConnSocket);
break;
case StageConnected:
Q_EMIT this->slotDataAvailable( nextConnSocket, info.instanceId );
this->slotDataAvailable( nextConnSocket, info.instanceId );
break;
default:
break;
@ -449,7 +449,7 @@ void SingleApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
}
if (sock->bytesAvailable() > 0){
Q_EMIT this->slotDataAvailable( sock, instanceId );
this->slotDataAvailable( sock, instanceId );
}
}
@ -462,7 +462,7 @@ void SingleApplicationPrivate::slotDataAvailable( QLocalSocket *dataSocket, quin
void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedSocket, quint32 instanceId )
{
if( closedSocket->bytesAvailable() > 0 )
Q_EMIT slotDataAvailable( closedSocket, instanceId );
slotDataAvailable( closedSocket, instanceId );
}
void SingleApplicationPrivate::randomSleep()