aboutsummaryrefslogtreecommitdiff
path: root/confui/ui_tab_node_overview.cpp
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-12-09 16:08:31 +0100
committerlonkaars <loek@pipeframe.xyz>2022-12-09 16:08:31 +0100
commit2eadbbd85105ad1199c43c72f551ddd69538e994 (patch)
tree333527c3edc00c1c4739e21d17030eaaa35b3fc8 /confui/ui_tab_node_overview.cpp
parent1d1799da8880b19aac0dbd2975facf97138bab61 (diff)
handle deleted nodes/automations properly
Diffstat (limited to 'confui/ui_tab_node_overview.cpp')
-rw-r--r--confui/ui_tab_node_overview.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/confui/ui_tab_node_overview.cpp b/confui/ui_tab_node_overview.cpp
index 84f1d6e..752bade 100644
--- a/confui/ui_tab_node_overview.cpp
+++ b/confui/ui_tab_node_overview.cpp
@@ -20,13 +20,17 @@ void CDNodeOverviewTabWidget::update() {
map<cd_uid_t, cd_s_node*> nodes = g_cd_mesh_connector->get_nodes(false);
for (pair<cd_uid_t, cd_s_node*> node : nodes) {
- if (node_widgets.count(node.first)) { // node is already in list
- node_widgets[node.first]->update();
- } else {
- node_widgets[node.first] = new CDNodeWidget(this);
+ if (node_widgets.count(node.first) == 0) {
+ node_widgets[node.first] = new CDNodeWidget(this); // create new node widget
node_widgets[node.first]->set_node(node.second);
node_widgets[node.first]->update();
+ main_layout->addWidget(node_widgets[node.first]);
+ } else if (node.second != nullptr) {
+ node_widgets[node.first]->update(); // update existing widget
+ } else if (node_widgets[node.first] != nullptr) {
+ main_layout->removeWidget(node_widgets[node.first]); // remove removed automation
+ delete node_widgets[node.first]; // free automation widget
+ node_widgets[node.first] = nullptr;
}
- main_layout->addWidget(node_widgets[node.first]);
}
}