aboutsummaryrefslogtreecommitdiff
path: root/confui/ui_tab_automations.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'confui/ui_tab_automations.cpp')
-rw-r--r--confui/ui_tab_automations.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/confui/ui_tab_automations.cpp b/confui/ui_tab_automations.cpp
index af02ab9..dae00ba 100644
--- a/confui/ui_tab_automations.cpp
+++ b/confui/ui_tab_automations.cpp
@@ -45,14 +45,18 @@ void CDAutomationsTabWidget::update() {
map<cd_link_t, cd_s_automation*> links = this->mainwindow->mesh_connector->get_links();
for (pair<cd_link_t, cd_s_automation*> link : links) {
- if (automation_widgets.count(link.first)) { // node is already in list
- automation_widgets[link.first]->update();
- } else {
- automation_widgets[link.first] = new CDAutomationWidget(this);
+ if (automation_widgets.count(link.first) == 0) {
+ automation_widgets[link.first] = new CDAutomationWidget(this); // create new automation
automation_widgets[link.first]->set_automation(link.first, link.second);
automation_widgets[link.first]->update();
+ automations->addWidget(automation_widgets[link.first]);
+ } else if (link.second != nullptr) {
+ automation_widgets[link.first]->update(); // update existing widget
+ } else if (automation_widgets[link.first] != nullptr) {
+ automations->removeWidget(automation_widgets[link.first]); // remove removed automation
+ delete automation_widgets[link.first]; // free automation widget
+ automation_widgets[link.first] = nullptr;
}
- automations->addWidget(automation_widgets[link.first]);
}
}