mirror of
https://git.alemi.dev/dashboard.git
synced 2024-11-14 11:59:18 +01:00
fix: avoid deadlock by doing it at the end
This commit is contained in:
parent
c026d0def3
commit
23f77a5819
1 changed files with 13 additions and 6 deletions
|
@ -14,6 +14,7 @@ use crate::app::{
|
||||||
use super::metric::{metric_display_ui, metric_edit_ui};
|
use super::metric::{metric_display_ui, metric_edit_ui};
|
||||||
|
|
||||||
pub fn source_panel(app: &mut App, ui: &mut Ui) {
|
pub fn source_panel(app: &mut App, ui: &mut Ui) {
|
||||||
|
let mut source_to_put_metric_on : Option<i32> = None;
|
||||||
let mut to_swap: Option<usize> = None;
|
let mut to_swap: Option<usize> = None;
|
||||||
let mut to_insert: Vec<Metric> = Vec::new();
|
let mut to_insert: Vec<Metric> = Vec::new();
|
||||||
// let mut to_delete: Option<usize> = None;
|
// let mut to_delete: Option<usize> = None;
|
||||||
|
@ -103,12 +104,7 @@ pub fn source_panel(app: &mut App, ui: &mut Ui) {
|
||||||
);
|
);
|
||||||
ui.add_space(2.0);
|
ui.add_space(2.0);
|
||||||
if ui.small_button(" + ").clicked() {
|
if ui.small_button(" + ").clicked() {
|
||||||
// TODO find a better
|
source_to_put_metric_on = Some(source.id);
|
||||||
if let Err(e) =
|
|
||||||
app.data.add_metric(&app.input_metric, source)
|
|
||||||
{
|
|
||||||
error!(target: "ui", "Error adding metric : {:?}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ui.add_space(1.0); // DAMN!
|
ui.add_space(1.0); // DAMN!
|
||||||
if ui.small_button("o").clicked() {
|
if ui.small_button("o").clicked() {
|
||||||
|
@ -208,6 +204,17 @@ pub fn source_panel(app: &mut App, ui: &mut Ui) {
|
||||||
metrics.push(m);
|
metrics.push(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Some(s) = source_to_put_metric_on {
|
||||||
|
for source in app.data.sources.read().expect("Sources RwLock poisoned").iter() {
|
||||||
|
if source.id == s {
|
||||||
|
if let Err(e) =
|
||||||
|
app.data.add_metric(&app.input_metric, &source)
|
||||||
|
{
|
||||||
|
error!(target: "ui", "Error adding metric : {:?}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn source_display_ui(ui: &mut Ui, source: &mut Source, _width: f32) {
|
pub fn source_display_ui(ui: &mut Ui, source: &mut Source, _width: f32) {
|
||||||
|
|
Loading…
Reference in a new issue