Skip to content

Commit

Permalink
Fixing compilation on Windows
Browse files Browse the repository at this point in the history
Condvar isn't UnwindSafe on Windows either. See
rust-lang/rust#118009
  • Loading branch information
ecton committed Dec 19, 2023
1 parent 7dc00f2 commit a1e3082
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ unicode-segmentation = "1.10.1"

# [patch."https://github.com/khonsulabs/kludgine"]
# kludgine = { path = "../kludgine" }
# [patch."https://github.com/khonsulabs/appit"]
# appit = { path = "../appit" }
# [patch.crates-io]
# appit = { version = "0.1.0", path = "../appit" }
# [patch."https://github.com/khonsulabs/figures"]
# figures = { path = "../figures" }

Expand Down
10 changes: 5 additions & 5 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use intentional::Assert;
use kludgine::app::winit::event::Modifiers;
use kludgine::app::winit::keyboard::ModifiersState;

/// This [`Condvar`] is a wrapper that on Mac OS/iOS asserts unwind safety. On
/// This [`Condvar`] is a wrapper that on Mac OS/iOS/Windows asserts unwind safety. On
/// all other platforms, this is a transparent wrapper around `Condvar`. See
/// <https://github.com/rust-lang/rust/issues/118009> for more information.
#[derive(Debug, Default)]
pub struct UnwindsafeCondvar(
#[cfg(any(target_os = "ios", target_os = "macos"))] std::panic::AssertUnwindSafe<Condvar>,
#[cfg(not(any(target_os = "ios", target_os = "macos")))] Condvar,
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "windows"))] std::panic::AssertUnwindSafe<Condvar>,
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "windows")))] Condvar,
);

impl Deref for UnwindsafeCondvar {
Expand All @@ -25,12 +25,12 @@ impl Deref for UnwindsafeCondvar {

impl UnwindsafeCondvar {
pub const fn new() -> Self {
#[cfg(any(target_os = "ios", target_os = "macos"))]
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "windows"))]
{
Self(std::panic::AssertUnwindSafe(Condvar::new()))
}

#[cfg(not(any(target_os = "ios", target_os = "macos")))]
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "windows")))]
{
Self(Condvar::new())
}
Expand Down
5 changes: 2 additions & 3 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::ffi::OsStr;
use std::ops::{Deref, DerefMut, Not};
use std::panic::{AssertUnwindSafe, UnwindSafe};
use std::path::Path;
use std::process::Command;
use std::string::ToString;
use std::sync::{MutexGuard, OnceLock};

Expand Down Expand Up @@ -1340,7 +1339,7 @@ impl Ranged for ThemeMode {
}

#[cfg(any(target_os = "macos", target_os = "ios", target_os = "windows"))]
fn default_family(query: Family<'_>) -> Option<FamilyOwned> {
fn default_family(_query: Family<'_>) -> Option<FamilyOwned> {
// fontdb uses system APIs to determine these defaults.
None
}
Expand All @@ -1360,7 +1359,7 @@ fn default_family(query: Family<'_>) -> Option<FamilyOwned> {
Family::Name(_) => return None,
};

Command::new("fc-match")
std::process::Command::new("fc-match")
.arg("-f")
.arg("%{family}")
.arg(query)
Expand Down

0 comments on commit a1e3082

Please sign in to comment.