Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version Mismatches in GUI #1554

Merged
merged 3 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/fj-host/src/host_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ impl HostThread {

self.send_event(ModelEvent::Evaluated)?;

if let Some(warn) = evaluation.warning {
self.send_event(ModelEvent::Warning(warn))?;
}

match self.shape_processor.process(&evaluation.shape) {
Ok(shape) => self.send_event(ModelEvent::ProcessedShape(shape))?,

Expand Down Expand Up @@ -136,6 +140,9 @@ pub enum ModelEvent {
/// The model has been processed
ProcessedShape(ProcessedShape),

/// A warning
Warning(String),

/// An error
Error(Error),
}
11 changes: 9 additions & 2 deletions crates/fj-host/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{

use fj::{abi, version::Version};
use fj_operations::shape_processor;
use tracing::{debug, warn};
use tracing::debug;

use crate::{platform::HostPlatform, Parameters};

Expand Down Expand Up @@ -86,6 +86,8 @@ impl Model {
.1
.trim();

let mut warnings = None;

// So, strictly speaking this is all unsound:
// - `Library::new` requires us to abide by the arbitrary requirements
// of any library initialization or termination routines.
Expand Down Expand Up @@ -140,7 +142,8 @@ impl Model {
.into_owned();
let model = version_full_model;

warn!("{}", Error::VersionMismatch { host, model });
warnings =
Some(format!("{}", Error::VersionMismatch { host, model }));
}

let init: libloading::Symbol<abi::InitFunction> = lib
Expand All @@ -164,6 +167,7 @@ impl Model {
Ok(Evaluation {
shape,
compile_time: seconds_taken.into(),
warning: warnings,
})
}
}
Expand All @@ -178,6 +182,9 @@ pub struct Evaluation {

/// The time it took to compile the shape, from the Cargo output
pub compile_time: String,

/// Warnings
pub warning: Option<String>,
}

pub struct Host<'a> {
Expand Down
3 changes: 3 additions & 0 deletions crates/fj-window/src/event_loop_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ impl EventLoopHandler {
ModelEvent::Error(err) => {
return Err(Box::new(err).into());
}
ModelEvent::Warning(warning) => {
self.status.update_status(&warning);
}
},
Event::WindowEvent {
event: WindowEvent::CloseRequested,
Expand Down