Skip to content

Commit d513bc2

Browse files
committed
Fix ci pipeline
1 parent 9be0963 commit d513bc2

2 files changed

Lines changed: 25 additions & 20 deletions

File tree

src/items/check.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,23 @@ impl CheckMenuItem {
168168

169169
/// Check or Uncheck this check menu item.
170170
pub fn set_checked(&self, checked: bool) {
171-
let mut inner = self.inner.borrow_mut();
172-
inner.set_checked(checked);
171+
#[cfg(target_os = "macos")]
172+
{
173+
let inner = self.inner.borrow();
174+
inner.set_checked(checked);
175+
}
173176

174-
#[cfg(all(feature = "linux-ksni", target_os = "linux"))]
175-
self.compat.store(Arc::new(Self::compat_menu_item(&inner)));
177+
#[cfg(not(target_os = "macos"))]
178+
{
179+
let mut inner = self.inner.borrow_mut();
180+
inner.set_checked(checked);
176181

177-
#[cfg(all(feature = "linux-ksni", target_os = "linux"))]
178-
crate::send_menu_update();
182+
#[cfg(all(feature = "linux-ksni", target_os = "linux"))]
183+
{
184+
self.compat.store(Arc::new(Self::compat_menu_item(&inner)));
185+
crate::send_menu_update();
186+
}
187+
}
179188
}
180189

181190
/// Convert this menu item into its menu ID.

src/platform_impl/windows/dark_menu_bar.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#![allow(non_snake_case, clippy::upper_case_acronyms)]
88

9+
use std::cell::OnceCell;
10+
911
use once_cell::sync::Lazy;
1012
use windows_sys::{
1113
s,
@@ -76,24 +78,18 @@ impl Drop for HBrush {
7678

7779
fn background_brush() -> HBRUSH {
7880
const BACKGROUND_COLOR: u32 = 2829099;
79-
static mut BACKGROUND_BRUSH: Option<HBrush> = None;
80-
unsafe {
81-
if BACKGROUND_BRUSH.is_none() {
82-
BACKGROUND_BRUSH = Some(HBrush(CreateSolidBrush(BACKGROUND_COLOR)));
83-
}
84-
BACKGROUND_BRUSH.as_ref().unwrap().0
85-
}
81+
static BACKGROUND_BRUSH: OnceCell<HBrush> = OnceCell::new();
82+
83+
let hbrush = BACKGROUND_BRUSH.get_or_init(|| HBrush(CreateSolidBrush(BACKGROUND_COLOR)));
84+
hbrush.as_ref().unwrap().0
8685
}
8786

8887
fn selected_background_brush() -> HBRUSH {
8988
const SELECTED_BACKGROUND_COLOR: u32 = 4276545;
90-
static mut SELECTED_BACKGROUND_BRUSH: Option<HBrush> = None;
91-
unsafe {
92-
if SELECTED_BACKGROUND_BRUSH.is_none() {
93-
SELECTED_BACKGROUND_BRUSH = Some(HBrush(CreateSolidBrush(SELECTED_BACKGROUND_COLOR)));
94-
}
95-
SELECTED_BACKGROUND_BRUSH.as_ref().unwrap().0
96-
}
89+
static SELECTED_BACKGROUND_BRUSH: OnceCell<HBrush> = OnceCell::new();
90+
91+
let hbrush = SELECTED_BACKGROUND_BRUSH.get_or_init(|| HBrush(CreateSolidBrush(SELECTED_BACKGROUND_COLOR)));
92+
hbrush.as_ref().unwrap().0
9793
}
9894

9995
/// Draws a dark menu bar if needed and returns whether it draws it or not

0 commit comments

Comments
 (0)