1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

RepaintSignal now implements Sync so it can be sent to another thread

Fixes https://github.com/emilk/egui/issues/82
This commit is contained in:
Emil Ernerfeldt
2020-12-27 10:49:26 +01:00
parent af1df8d339
commit 958fc2753a
3 changed files with 14 additions and 5 deletions

View File

@@ -31,11 +31,13 @@ impl egui::app::TextureAllocator for Painter {
struct RequestRepaintEvent;
struct GliumRepaintSignal(glutin::event_loop::EventLoopProxy<RequestRepaintEvent>);
struct GliumRepaintSignal(
std::sync::Mutex<glutin::event_loop::EventLoopProxy<RequestRepaintEvent>>,
);
impl egui::app::RepaintSignal for GliumRepaintSignal {
fn request_repaint(&self) {
self.0.send_event(RequestRepaintEvent).ok();
self.0.lock().unwrap().send_event(RequestRepaintEvent).ok();
}
}
@@ -105,7 +107,9 @@ pub fn run(mut app: Box<dyn App>) -> ! {
let event_loop = glutin::event_loop::EventLoop::with_user_event();
let display = create_display(app.name(), window_settings, app.is_resizable(), &event_loop);
let repaint_signal = std::sync::Arc::new(GliumRepaintSignal(event_loop.create_proxy()));
let repaint_signal = std::sync::Arc::new(GliumRepaintSignal(std::sync::Mutex::new(
event_loop.create_proxy(),
)));
let mut ctx = egui::CtxRef::default();
*ctx.memory() = storage