diff --git a/src/ui.rs b/src/ui.rs index a910c2e..3154951 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -188,7 +188,7 @@ fn gtk_delete(comps: &UiMutex, shell: &RefCell) -> Inhibit { } pub struct UiMutex { - thread: String, + thread: thread::ThreadId, data: RefCell, } @@ -198,10 +198,7 @@ unsafe impl Sync for UiMutex {} impl UiMutex { pub fn new(t: T) -> UiMutex { UiMutex { - thread: thread::current() - .name() - .expect("Can create UI only from main thread, current thiread has no name") - .to_owned(), + thread: thread::current().id(), data: RefCell::new(t), } } @@ -220,12 +217,8 @@ impl UiMutex { #[inline] fn assert_ui_thread(&self) { - match thread::current().name() { - Some(name) if name == self.thread => (), - Some(name) => { - panic!("Can create UI only from main thread, {}", name); - } - None => panic!("Can create UI only from main thread, current thread has no name"), + if thread::current().id() != self.thread { + panic!("Can access to UI only from main thread"); } } }