Clean up preferred connection if it vanishes
This commit is contained in:
parent
45581e7f30
commit
ee3c8ce7d2
@ -132,6 +132,8 @@ void NymeaConnection::setCurrentHost(NymeaHost *host)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_preferredConnection = nullptr;
|
||||||
|
|
||||||
if (m_currentTransport) {
|
if (m_currentTransport) {
|
||||||
m_currentTransport = nullptr;
|
m_currentTransport = nullptr;
|
||||||
emit currentConnectionChanged();
|
emit currentConnectionChanged();
|
||||||
@ -459,6 +461,10 @@ void NymeaConnection::connectToHost(NymeaHost *nymeaHost, Connection *connection
|
|||||||
if (nymeaHost->connections()->find(connection->url())) {
|
if (nymeaHost->connections()->find(connection->url())) {
|
||||||
qCInfo(dcNymeaConnection()) << "Setting preferred connection to" << connection->url();
|
qCInfo(dcNymeaConnection()) << "Setting preferred connection to" << connection->url();
|
||||||
m_preferredConnection = connection;
|
m_preferredConnection = connection;
|
||||||
|
// Unset the preferred connection when it is removed
|
||||||
|
connect(connection, &Connection::destroyed, this, [=](){
|
||||||
|
m_preferredConnection = nullptr;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcNymeaConnection()) << "Connection" << connection << "is not a candidate for" << nymeaHost->name() << "Not setting preferred connection.";
|
qCWarning(dcNymeaConnection()) << "Connection" << connection << "is not a candidate for" << nymeaHost->name() << "Not setting preferred connection.";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user