Remove probably not needed mutex

This commit is contained in:
hodasemi 2024-03-27 13:02:53 +01:00
parent 5de3f49841
commit 47163b097b

View file

@ -159,7 +159,7 @@ impl<'a, T: TopLevelGui + 'static> From<T> for CreationType<'a> {
pub struct States {
gui_handler: Arc<GuiHandler>,
states: Mutex<HashMap<String, Arc<State>>>,
states: HashMap<String, Arc<State>>,
current_state: Mutex<Option<Arc<State>>>,
control_top_gui: AtomicBool,
@ -173,7 +173,7 @@ impl States {
Ok(States {
gui_handler,
states: Mutex::new(HashMap::new()),
states: HashMap::new(),
current_state: Mutex::new(None),
control_top_gui: AtomicBool::new(true),
@ -193,11 +193,11 @@ impl States {
/// Adds a single state
pub fn add_state<'a>(
&self,
&mut self,
id: &str,
creation_type: impl Into<CreationType<'a>>,
) -> Result<()> {
self.states.lock().unwrap().insert(
self.states.insert(
id.to_string(),
State::new(&self.gui_handler, id, creation_type.into())?,
);
@ -274,9 +274,7 @@ impl States {
}
fn get_state(&self, id: &str) -> Result<Arc<State>> {
let states = self.states.lock().unwrap();
match states.get(id) {
match self.states.get(id) {
Some(state) => Ok(state.clone()),
None => Err(anyhow::Error::msg(format!("UiState not found: {}", id))),
}