Destroying a socket should not destroy the link.
Also, sockets can be destroyed as soon as the socketreader is deleted.
This commit is contained in:
parent
83a56c47e9
commit
e379fcd69d
3 changed files with 5 additions and 2 deletions
|
@ -39,6 +39,7 @@ LanDeviceLink::LanDeviceLink(const QString& deviceId, LinkProvider* parent, QSsl
|
||||||
void LanDeviceLink::reset(QSslSocket* socket, ConnectionStarted connectionSource)
|
void LanDeviceLink::reset(QSslSocket* socket, ConnectionStarted connectionSource)
|
||||||
{
|
{
|
||||||
if (mSocketLineReader) {
|
if (mSocketLineReader) {
|
||||||
|
disconnect(mSocketLineReader->mSocket, SIGNAL(disconnected()), this, SLOT(deleteLater()));
|
||||||
delete mSocketLineReader;
|
delete mSocketLineReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ void LanDeviceLink::reset(QSslSocket* socket, ConnectionStarted connectionSource
|
||||||
//When the link provider destroys us,
|
//When the link provider destroys us,
|
||||||
//the socket (and the reader) will be
|
//the socket (and the reader) will be
|
||||||
//destroyed as well
|
//destroyed as well
|
||||||
socket->setParent(this);
|
socket->setParent(mSocketLineReader);
|
||||||
|
|
||||||
mConnectionSource = connectionSource;
|
mConnectionSource = connectionSource;
|
||||||
|
|
||||||
|
|
|
@ -473,6 +473,7 @@ void LanLinkProvider::addLink(const QString& deviceId, QSslSocket* socket, Netwo
|
||||||
//Do we have a link for this device already?
|
//Do we have a link for this device already?
|
||||||
QMap< QString, LanDeviceLink* >::iterator linkIterator = mLinks.find(deviceId);
|
QMap< QString, LanDeviceLink* >::iterator linkIterator = mLinks.find(deviceId);
|
||||||
if (linkIterator != mLinks.end()) {
|
if (linkIterator != mLinks.end()) {
|
||||||
|
//qCDebug(KDECONNECT_CORE) << "Reusing link to" << deviceId;
|
||||||
deviceLink = linkIterator.value();
|
deviceLink = linkIterator.value();
|
||||||
deviceLink->reset(socket, connectionOrigin);
|
deviceLink->reset(socket, connectionOrigin);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -47,6 +47,8 @@ public:
|
||||||
QSslCertificate peerCertificate() const { return mSocket->peerCertificate(); }
|
QSslCertificate peerCertificate() const { return mSocket->peerCertificate(); }
|
||||||
qint64 bytesAvailable() const { return mPackages.size(); }
|
qint64 bytesAvailable() const { return mPackages.size(); }
|
||||||
|
|
||||||
|
QSslSocket* mSocket;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void readyRead();
|
void readyRead();
|
||||||
|
|
||||||
|
@ -55,7 +57,6 @@ private Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QByteArray lastChunk;
|
QByteArray lastChunk;
|
||||||
QSslSocket* mSocket;
|
|
||||||
QQueue<QByteArray> mPackages;
|
QQueue<QByteArray> mPackages;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue