Remove probably not needed mutex
This commit is contained in:
parent
5de3f49841
commit
47163b097b
1 changed files with 5 additions and 7 deletions
|
@ -159,7 +159,7 @@ impl<'a, T: TopLevelGui + 'static> From<T> for CreationType<'a> {
|
||||||
pub struct States {
|
pub struct States {
|
||||||
gui_handler: Arc<GuiHandler>,
|
gui_handler: Arc<GuiHandler>,
|
||||||
|
|
||||||
states: Mutex<HashMap<String, Arc<State>>>,
|
states: HashMap<String, Arc<State>>,
|
||||||
current_state: Mutex<Option<Arc<State>>>,
|
current_state: Mutex<Option<Arc<State>>>,
|
||||||
|
|
||||||
control_top_gui: AtomicBool,
|
control_top_gui: AtomicBool,
|
||||||
|
@ -173,7 +173,7 @@ impl States {
|
||||||
Ok(States {
|
Ok(States {
|
||||||
gui_handler,
|
gui_handler,
|
||||||
|
|
||||||
states: Mutex::new(HashMap::new()),
|
states: HashMap::new(),
|
||||||
current_state: Mutex::new(None),
|
current_state: Mutex::new(None),
|
||||||
|
|
||||||
control_top_gui: AtomicBool::new(true),
|
control_top_gui: AtomicBool::new(true),
|
||||||
|
@ -193,11 +193,11 @@ impl States {
|
||||||
|
|
||||||
/// Adds a single state
|
/// Adds a single state
|
||||||
pub fn add_state<'a>(
|
pub fn add_state<'a>(
|
||||||
&self,
|
&mut self,
|
||||||
id: &str,
|
id: &str,
|
||||||
creation_type: impl Into<CreationType<'a>>,
|
creation_type: impl Into<CreationType<'a>>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
self.states.lock().unwrap().insert(
|
self.states.insert(
|
||||||
id.to_string(),
|
id.to_string(),
|
||||||
State::new(&self.gui_handler, id, creation_type.into())?,
|
State::new(&self.gui_handler, id, creation_type.into())?,
|
||||||
);
|
);
|
||||||
|
@ -274,9 +274,7 @@ impl States {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_state(&self, id: &str) -> Result<Arc<State>> {
|
fn get_state(&self, id: &str) -> Result<Arc<State>> {
|
||||||
let states = self.states.lock().unwrap();
|
match self.states.get(id) {
|
||||||
|
|
||||||
match states.get(id) {
|
|
||||||
Some(state) => Ok(state.clone()),
|
Some(state) => Ok(state.clone()),
|
||||||
None => Err(anyhow::Error::msg(format!("UiState not found: {}", id))),
|
None => Err(anyhow::Error::msg(format!("UiState not found: {}", id))),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue