mirror of https://github.com/hannobraun/Fornjot
Merge pull request #1304 from hannobraun/version
Fix panic on Windows when loading model version
This commit is contained in:
commit
eae922bdde
|
@ -108,15 +108,13 @@ impl Model {
|
||||||
let version_pkg: libloading::Symbol<fn() -> RawVersion> =
|
let version_pkg: libloading::Symbol<fn() -> RawVersion> =
|
||||||
lib.get(b"version_pkg").map_err(Error::LoadingVersion)?;
|
lib.get(b"version_pkg").map_err(Error::LoadingVersion)?;
|
||||||
|
|
||||||
let version_pkg = version_pkg();
|
let version_pkg = version_pkg().to_string();
|
||||||
if fj::version::VERSION_PKG != version_pkg.as_str() {
|
if fj::version::VERSION_PKG != version_pkg {
|
||||||
let host = String::from_utf8_lossy(
|
let host = String::from_utf8_lossy(
|
||||||
fj::version::VERSION_PKG.as_bytes(),
|
fj::version::VERSION_PKG.as_bytes(),
|
||||||
)
|
)
|
||||||
.into_owned();
|
.into_owned();
|
||||||
let model =
|
let model = version_pkg;
|
||||||
String::from_utf8_lossy(version_pkg.as_str().as_bytes())
|
|
||||||
.into_owned();
|
|
||||||
|
|
||||||
return Err(Error::VersionMismatch { host, model });
|
return Err(Error::VersionMismatch { host, model });
|
||||||
}
|
}
|
||||||
|
@ -124,15 +122,13 @@ impl Model {
|
||||||
let version_full: libloading::Symbol<fn() -> RawVersion> =
|
let version_full: libloading::Symbol<fn() -> RawVersion> =
|
||||||
lib.get(b"version_full").map_err(Error::LoadingVersion)?;
|
lib.get(b"version_full").map_err(Error::LoadingVersion)?;
|
||||||
|
|
||||||
let version_full = version_full();
|
let version_full = version_full().to_string();
|
||||||
if fj::version::VERSION_FULL != version_full.as_str() {
|
if fj::version::VERSION_FULL != version_full {
|
||||||
let host = String::from_utf8_lossy(
|
let host = String::from_utf8_lossy(
|
||||||
fj::version::VERSION_FULL.as_bytes(),
|
fj::version::VERSION_FULL.as_bytes(),
|
||||||
)
|
)
|
||||||
.into_owned();
|
.into_owned();
|
||||||
let model =
|
let model = version_full;
|
||||||
String::from_utf8_lossy(version_full.as_str().as_bytes())
|
|
||||||
.into_owned();
|
|
||||||
|
|
||||||
warn!("{}", Error::VersionMismatch { host, model });
|
warn!("{}", Error::VersionMismatch { host, model });
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,19 +102,7 @@ pub fn run(
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelEvent::Error(err) => {
|
ModelEvent::Error(err) => {
|
||||||
// Can be cleaned up, once `Report` is stable:
|
status.update_status(&err.to_string());
|
||||||
// https://doc.rust-lang.org/std/error/struct.Report.html
|
|
||||||
|
|
||||||
println!("Error receiving updated shape: {}", err);
|
|
||||||
|
|
||||||
let mut current_err = &err as &dyn error::Error;
|
|
||||||
while let Some(err) = current_err.source() {
|
|
||||||
println!();
|
|
||||||
println!("Caused by:");
|
|
||||||
println!(" {}", err);
|
|
||||||
|
|
||||||
current_err = err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,10 @@ impl RawVersion {
|
||||||
///
|
///
|
||||||
/// Must be a `RawVersion` returned from one of the hidden version functions
|
/// Must be a `RawVersion` returned from one of the hidden version functions
|
||||||
/// in this module.
|
/// in this module.
|
||||||
pub unsafe fn as_str(&self) -> &str {
|
#[allow(clippy::inherent_to_string)]
|
||||||
|
pub unsafe fn to_string(&self) -> String {
|
||||||
let slice = slice::from_raw_parts(self.ptr, self.len);
|
let slice = slice::from_raw_parts(self.ptr, self.len);
|
||||||
std::str::from_utf8(slice).unwrap()
|
String::from_utf8_lossy(slice).into_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue