Skip to content

Commit

Permalink
fix(macos): crashing when setting theme to none (#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master authored Oct 28, 2024
1 parent 8d094bb commit 67e44e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changes/set-theme-none-macos-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

Fix setting theme to `None` crashes the app on macOS
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 67e44e4

Please sign in to comment.