Job state handling cleanup

This commit is contained in:
2023-08-09 19:39:06 -04:00
parent f5f6869029
commit 94924047b7
10 changed files with 102 additions and 76 deletions

View File

@@ -18,7 +18,7 @@ use self_update::cargo_crate_version;
use crate::{
app::{AppConfig, DiffKind, ViewConfig, ViewState},
config::{ProjectUnit, ProjectUnitNode},
jobs::{bindiff::queue_bindiff, objdiff::queue_build, update::queue_update},
jobs::{bindiff::start_bindiff, objdiff::start_build, update::start_update},
update::RELEASE_URL,
};
@@ -101,7 +101,7 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
)
.clicked()
{
view_state.jobs.push(queue_update());
view_state.jobs.push(start_update());
}
if ui
.button("Manual")
@@ -190,7 +190,7 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
build = true;
}
if build {
view_state.jobs.push(queue_build(config.clone(), view_state.diff_config.clone()));
view_state.jobs.push(start_build(config.clone(), view_state.diff_config.clone()));
}
}
} else if view_state.diff_kind == DiffKind::WholeBinary {
@@ -218,7 +218,7 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
if let (Some(_), Some(_)) = (left_obj, right_obj) {
if ui.button("Build").clicked() {
view_state.jobs.push(queue_bindiff(config.clone()));
view_state.jobs.push(start_bindiff(config.clone()));
}
}
}

View File

@@ -212,7 +212,7 @@ pub fn data_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
ui.scope(|ui| {
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
ui.style_mut().wrap = Some(false);
if view_state.jobs.iter().any(|job| job.job_type == Job::ObjDiff) {
if view_state.jobs.is_running(Job::ObjDiff) {
ui.colored_label(view_state.view_config.replace_color, "Building…");
} else {
ui.label("Last built:");

View File

@@ -445,7 +445,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
ui.scope(|ui| {
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
ui.style_mut().wrap = Some(false);
if view_state.jobs.iter().any(|job| job.job_type == Job::ObjDiff) {
if view_state.jobs.is_running(Job::ObjDiff) {
ui.colored_label(view_state.view_config.replace_color, "Building…");
} else {
ui.label("Last built:");

View File

@@ -6,7 +6,7 @@ pub fn jobs_ui(ui: &mut egui::Ui, view_state: &mut ViewState) {
ui.label("Jobs");
let mut remove_job: Option<usize> = None;
for (idx, job) in view_state.jobs.iter_mut().enumerate() {
for job in view_state.jobs.iter_mut() {
let Ok(status) = job.status.read() else {
continue;
};
@@ -20,7 +20,7 @@ pub fn jobs_ui(ui: &mut egui::Ui, view_state: &mut ViewState) {
log::error!("Failed to cancel job: {e:?}");
}
} else {
remove_job = Some(idx);
remove_job = Some(job.id);
}
}
});