Skip to content

Commit

Permalink
"Fix" #8
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamVenner committed Feb 28, 2022
1 parent 4db172c commit c94df16
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ target/
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
**/*.rs.bk

wix311/
wix311.zip
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blackhole"
version = "4.0.0"
version = "4.0.1"
authors = ["William Venner <[email protected]>"]
edition = "2018"
repository = "https://github.com/WilliamVenner/blackhole"
Expand All @@ -16,12 +16,16 @@ icon = ["src/assets/blackhole.ico"]
[features]
gui = ["msgbox", "opener"]

[profile.release]
debug = true

[dependencies]
dirs = "3.0"
trash = "1.2"
fs_extra = "1.2"
msgbox = { version = "0.6.0", optional = true }
opener = { version = "0.4.1", optional = true }
backtrace = "0.3"

[target.'cfg(target_os="macos")'.dependencies]
embed_plist = "1.2"
Expand Down
8 changes: 5 additions & 3 deletions src/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ pub mod show {
#[cfg(feature="gui")]
impl Show {
pub fn panic(err: &String) {
if msgbox::create("Blackhole PANIC", err, IconType::Error).is_err() {
let err = format!("{}\n\n{:#?}", err, backtrace::Backtrace::new());
if msgbox::create("Blackhole PANIC", &err, IconType::Error).is_err() {
panic!("Blackhole PANIC: {}", err);
}
}

pub fn error(err: &String) {
if msgbox::create("Blackhole ERROR", err, IconType::Error).is_err() {
println!("Blackhole ERROR: {}", err);
let err = format!("{}\n\n{:#?}", err, backtrace::Backtrace::new());
if msgbox::create("Blackhole ERROR", &err, IconType::Error).is_err() {
eprintln!("Blackhole ERROR: {}", err);
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ impl Windows for Blackhole {
.output() {
Err(err) => { Show::error(&format!("Error executing PowerShell script: {}", err)) },
Ok(output) => {
if std::str::from_utf8(&output.stderr).map(|str| str.contains("called on MessageLoop that's already been Quit!")).unwrap_or(false) {
// A silly fix for a silly error (the script still worked)
return;
}

if output.stderr.len() > 0 {
Show::error(&format!("PowerShell error:\n{}", String::from_utf8(output.stderr).unwrap_or_else(|_| String::from("String conversion error"))));
}
Expand Down

0 comments on commit c94df16

Please sign in to comment.