Skip to content

Commit

Permalink
Fix crashing on macos when setting theme to none
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master committed Oct 22, 2024
1 parent c49b83a commit 30c680c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/platform_impl/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,15 @@ pub(super) fn set_ns_theme(theme: Option<Theme>) {
let app: id = msg_send![app_class, sharedApplication];
let has_theme: BOOL = msg_send![app, respondsToSelector: sel!(effectiveAppearance)];
if has_theme == YES {
let name = if let Some(theme) = theme {
NSString::alloc(nil).init_str(match theme {
let appearance = if let Some(theme) = theme {
let name = NSString::alloc(nil).init_str(match theme {
Theme::Dark => "NSAppearanceNameDarkAqua",
Theme::Light => "NSAppearanceNameAqua",
})
});
msg_send![class!(NSAppearance), appearanceNamed: name]
} else {
nil
};
let appearance: id = msg_send![class!(NSAppearance), appearanceNamed: name];
let _: () = msg_send![app, setAppearance: appearance];
}
}
Expand Down

0 comments on commit 30c680c

Please sign in to comment.