Merge PR #760: Fix crash when syncing remote connection configs via a remote connection

This commit is contained in:
Jenkins nymea 2022-02-06 12:04:49 +01:00
commit 6ee4a2e007
5 changed files with 12 additions and 17 deletions

View File

@ -41,6 +41,10 @@ ServerConfiguration::ServerConfiguration(const QString &id, const QString &addre
}
ServerConfiguration::~ServerConfiguration()
{
}
QString ServerConfiguration::id() const
{
return m_id;

View File

@ -46,6 +46,7 @@ class ServerConfiguration : public QObject
public:
explicit ServerConfiguration(const QString &id, const QString &address = QString(), int port = 0, bool authEnabled = false, bool sslEnabled = false, QObject *parent = nullptr);
virtual ~ServerConfiguration();
QString id() const;

View File

@ -101,21 +101,6 @@ bool NymeaHost::online() const
return m_online;
}
void NymeaHost::addTunnelConnection()
{
for (int i = 0; i < m_connections->rowCount(); i++) {
if (m_connections->get(i)->url().scheme() == "tunnel") {
return;
}
}
QUrl url;
url.setScheme("tunnel");
url.setHost(m_uuid.toString().remove(QRegExp("[{}]")));
qCritical() << "Adding tunnel connection" << url << m_uuid;
Connection *connection = new Connection(url, Connection::BearerTypeCloud, true, "foooobaaaar", this);
m_connections->addConnection(connection);
}
void NymeaHost::syncOnlineState()
{
for (int i = 0; i < m_connections->rowCount(); i++) {

View File

@ -158,8 +158,6 @@ public:
bool online() const;
Q_INVOKABLE void addTunnelConnection();
signals:
void nameChanged();
void versionChanged();

View File

@ -352,6 +352,13 @@ Item {
}
function syncRemoteConnection() {
if (engine.jsonRpcClient.currentConnection.url.toString().startsWith("tunnel")) {
// Not resyncing tunnel configurations while we're connected through a tunnel ourselves
// (We could, maybe even should, but currently libnymea-app borrows the "NymeaHost" pointer from
// the hostsmodel and will crash if we delete the used Connection object)
return;
}
for (var i = 0; i < engine.jsonRpcClient.currentHost.connections.count; i++) {
var connection = engine.jsonRpcClient.currentHost.connections.get(i)
if (connection.url.toString().startsWith("tunnel")) {