diff --git a/nymea-app/configuredhostsmodel.cpp b/nymea-app/configuredhostsmodel.cpp index cc562150..d01dc82c 100644 --- a/nymea-app/configuredhostsmodel.cpp +++ b/nymea-app/configuredhostsmodel.cpp @@ -120,6 +120,11 @@ void ConfiguredHostsModel::removeHost(int index) if (m_list.isEmpty()) { createHost(); } + + if (m_currentIndex >= m_list.count()) { + m_currentIndex = m_list.count() - 1; + emit currentIndexChanged(); + } } int ConfiguredHostsModel::indexOf(ConfiguredHost *host) const diff --git a/nymea-app/ui/MainMenu.qml b/nymea-app/ui/MainMenu.qml index e45953e9..15b4dd14 100644 --- a/nymea-app/ui/MainMenu.qml +++ b/nymea-app/ui/MainMenu.qml @@ -8,7 +8,7 @@ Drawer { id: root property ConfiguredHostsModel configuredHosts: null - readonly property Engine currentEngine: configuredHosts.get(configuredHosts.currentIndex).engine + readonly property Engine currentEngine: configuredHosts.count > 0 ? configuredHosts.get(configuredHosts.currentIndex).engine : null signal openThingSettings(); signal openMagicSettings();