diff options
| author | Andreas Grois <andi@grois.info> | 2021-05-01 17:01:17 +0200 |
|---|---|---|
| committer | Andreas Grois <andi@grois.info> | 2021-05-01 17:01:17 +0200 |
| commit | 00a3332d9a986f650283416dccf25aa9f2d32aa6 (patch) | |
| tree | 6df1c2b748e93dd37c7042a24801d98ed90a1cbf | |
| parent | 84c4117080185ef54c13abcc54027df2c3f8800f (diff) | |
Fix error messages if library could not be loaded.
Previously rather useless memory addresses were written in user-visible
error messages. Now it's the actual file path.
| -rw-r--r-- | swaystatus/src/plugin_database/mod.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/swaystatus/src/plugin_database/mod.rs b/swaystatus/src/plugin_database/mod.rs index a4693ed..872f645 100644 --- a/swaystatus/src/plugin_database/mod.rs +++ b/swaystatus/src/plugin_database/mod.rs @@ -16,11 +16,11 @@ impl<'a> PluginDatabase<'a> { } pub fn new<'b : 'a>(libs : &'b Libraries) -> PluginDatabase<'a> { PluginDatabase { - plugins : libs.libs.iter().filter_map(|lib| { + plugins : libs.libs.iter().filter_map(|(path, lib)| { match get_plugin_from_library(lib) { Ok(x) => Some((String::from(x.get_name()), x)), Err(y) => { - let lib_name = format!("{:?}", lib); + let lib_name = path.to_string_lossy(); match y { PluginLoadingError::MissingVersionInformation => { eprintln!("{}", gettext!("Failed to load library {}, no version information found.", lib_name)); @@ -46,7 +46,7 @@ impl<'a> PluginDatabase<'a> { } pub struct Libraries { - libs : Vec<Library> + libs : Vec<(std::path::PathBuf,Library)> } impl Libraries { pub fn load_from_folder(path : &std::path::Path) -> Result<Libraries, std::io::Error> { @@ -58,8 +58,9 @@ impl Libraries { None }, Ok(d) => unsafe { - match libloading::Library::new(d.path()) { - Ok(x) => Some(x), + let p = d.path(); + match libloading::Library::new(&p) { + Ok(x) => Some((p,x)), Err(_) => { eprintln!("{}", gettext!("Failed to load as library: {}", d.path().display())); None |
