fix: Use globals instead of thread-locals

Better support for multi-threaded applications,
especially cosmic-comp rendering in parallel on
multiple threads, each potentially accessing
global configurations such as the active theme,
icon_theme and more...
This commit is contained in:
Victoria Brekenfeld 2024-08-02 20:00:16 +02:00 committed by Michael Murphy
parent f655710d55
commit b40839638a
16 changed files with 183 additions and 216 deletions

View file

@ -375,10 +375,7 @@ pub fn run<App: Application>(autosize: bool, flags: App::Flags) -> iced::Result
core.set_window_width(width);
core.set_window_height(height);
THEME.with(move |t| {
let mut cosmic_theme = t.borrow_mut();
cosmic_theme.set_theme(settings.theme.theme_type);
});
THEME.lock().unwrap().set_theme(settings.theme.theme_type);
let mut iced = iced::Settings::with_flags((core, flags));
@ -435,11 +432,7 @@ pub fn padded_control<'a, Message>(
}
pub fn menu_control_padding() -> Padding {
THEME
.with(|t| {
let t = t.borrow();
let cosmic = t.cosmic();
[cosmic.space_xxs(), cosmic.space_m()]
})
.into()
let guard = THEME.lock().unwrap();
let cosmic = guard.cosmic();
[cosmic.space_xxs(), cosmic.space_m()].into()
}