mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 14:20:04 -04:00
Remove unused Rc<RefCell<T>>
This commit is contained in:
@@ -872,7 +872,7 @@ mod glow_integration {
|
|||||||
repaint_proxy: Arc<egui::mutex::Mutex<EventLoopProxy<UserEvent>>>,
|
repaint_proxy: Arc<egui::mutex::Mutex<EventLoopProxy<UserEvent>>>,
|
||||||
app_name: String,
|
app_name: String,
|
||||||
native_options: epi::NativeOptions,
|
native_options: epi::NativeOptions,
|
||||||
running: Rc<RefCell<Option<GlowWinitRunning>>>,
|
running: Option<GlowWinitRunning>,
|
||||||
|
|
||||||
// Note that since this `AppCreator` is FnOnce we are currently unable to support
|
// Note that since this `AppCreator` is FnOnce we are currently unable to support
|
||||||
// re-initializing the `GlowWinitRunning` state on Android if the application
|
// re-initializing the `GlowWinitRunning` state on Android if the application
|
||||||
@@ -893,7 +893,7 @@ mod glow_integration {
|
|||||||
repaint_proxy: Arc::new(egui::mutex::Mutex::new(event_loop.create_proxy())),
|
repaint_proxy: Arc::new(egui::mutex::Mutex::new(event_loop.create_proxy())),
|
||||||
app_name: app_name.to_owned(),
|
app_name: app_name.to_owned(),
|
||||||
native_options,
|
native_options,
|
||||||
running: Rc::new(RefCell::new(None)),
|
running: None,
|
||||||
app_creator: Some(app_creator),
|
app_creator: Some(app_creator),
|
||||||
focused_viewport: Rc::new(RefCell::new(Some(ViewportId::ROOT))),
|
focused_viewport: Rc::new(RefCell::new(Some(ViewportId::ROOT))),
|
||||||
}
|
}
|
||||||
@@ -1110,13 +1110,13 @@ mod glow_integration {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.running.replace(Some(GlowWinitRunning {
|
self.running.replace(GlowWinitRunning {
|
||||||
glutin_ctx,
|
glutin_ctx,
|
||||||
gl,
|
gl,
|
||||||
painter,
|
painter,
|
||||||
integration: Rc::new(RefCell::new(integration)),
|
integration: Rc::new(RefCell::new(integration)),
|
||||||
app: Rc::new(RefCell::new(app)),
|
app: Rc::new(RefCell::new(app)),
|
||||||
}));
|
});
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1347,14 +1347,14 @@ mod glow_integration {
|
|||||||
|
|
||||||
impl WinitApp for GlowWinitApp {
|
impl WinitApp for GlowWinitApp {
|
||||||
fn frame_nr(&self, viewport_id: ViewportId) -> u64 {
|
fn frame_nr(&self, viewport_id: ViewportId) -> u64 {
|
||||||
self.running.borrow().as_ref().map_or(0, |r| {
|
self.running.as_ref().map_or(0, |r| {
|
||||||
r.integration.borrow().egui_ctx.frame_nr_for(viewport_id)
|
r.integration.borrow().egui_ctx.frame_nr_for(viewport_id)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_focused(&self, window_id: winit::window::WindowId) -> bool {
|
fn is_focused(&self, window_id: winit::window::WindowId) -> bool {
|
||||||
if let Some(is_focused) = self.focused_viewport.borrow().as_ref() {
|
if let Some(is_focused) = self.focused_viewport.borrow().as_ref() {
|
||||||
if let Some(running) = self.running.borrow().as_ref() {
|
if let Some(running) = self.running.as_ref() {
|
||||||
if let Some(window_id) =
|
if let Some(window_id) =
|
||||||
running.glutin_ctx.borrow().viewport_maps.get(&window_id)
|
running.glutin_ctx.borrow().viewport_maps.get(&window_id)
|
||||||
{
|
{
|
||||||
@@ -1366,17 +1366,14 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn integration(&self) -> Option<Rc<RefCell<EpiIntegration>>> {
|
fn integration(&self) -> Option<Rc<RefCell<EpiIntegration>>> {
|
||||||
self.running
|
self.running.as_ref().map(|r| r.integration.clone())
|
||||||
.borrow()
|
|
||||||
.as_ref()
|
|
||||||
.map(|r| r.integration.clone())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn window(
|
fn window(
|
||||||
&self,
|
&self,
|
||||||
window_id: winit::window::WindowId,
|
window_id: winit::window::WindowId,
|
||||||
) -> Option<Rc<RefCell<winit::window::Window>>> {
|
) -> Option<Rc<RefCell<winit::window::Window>>> {
|
||||||
self.running.borrow().as_ref().and_then(|r| {
|
self.running.as_ref().and_then(|r| {
|
||||||
let glutin_ctx = r.glutin_ctx.borrow();
|
let glutin_ctx = r.glutin_ctx.borrow();
|
||||||
if let Some(viewport_id) = glutin_ctx.viewport_maps.get(&window_id) {
|
if let Some(viewport_id) = glutin_ctx.viewport_maps.get(&window_id) {
|
||||||
if let Some(viewport) = glutin_ctx.viewports.get(viewport_id) {
|
if let Some(viewport) = glutin_ctx.viewports.get(viewport_id) {
|
||||||
@@ -1391,21 +1388,19 @@ mod glow_integration {
|
|||||||
|
|
||||||
fn window_id_from_viewport_id(&self, id: ViewportId) -> Option<winit::window::WindowId> {
|
fn window_id_from_viewport_id(&self, id: ViewportId) -> Option<winit::window::WindowId> {
|
||||||
self.running
|
self.running
|
||||||
.borrow()
|
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|r| r.glutin_ctx.borrow().window_maps.get(&id).copied())
|
.and_then(|r| r.glutin_ctx.borrow().window_maps.get(&id).copied())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn viewport_id_from_window_id(&self, id: &winit::window::WindowId) -> Option<ViewportId> {
|
fn viewport_id_from_window_id(&self, id: &winit::window::WindowId) -> Option<ViewportId> {
|
||||||
self.running
|
self.running
|
||||||
.borrow()
|
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|r| r.glutin_ctx.borrow().viewport_maps.get(id).copied())
|
.and_then(|r| r.glutin_ctx.borrow().viewport_maps.get(id).copied())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_and_destroy(&mut self) {
|
fn save_and_destroy(&mut self) {
|
||||||
crate::profile_function!();
|
crate::profile_function!();
|
||||||
if let Some(running) = self.running.borrow_mut().take() {
|
if let Some(running) = self.running.take() {
|
||||||
crate::profile_function!();
|
crate::profile_function!();
|
||||||
|
|
||||||
running.integration.borrow_mut().save(
|
running.integration.borrow_mut().save(
|
||||||
@@ -1426,7 +1421,7 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_ui_and_paint(&mut self, window_id: winit::window::WindowId) -> EventResult {
|
fn run_ui_and_paint(&mut self, window_id: winit::window::WindowId) -> EventResult {
|
||||||
if self.running.borrow().is_none() {
|
if self.running.is_none() {
|
||||||
return EventResult::Wait;
|
return EventResult::Wait;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1439,8 +1434,7 @@ mod glow_integration {
|
|||||||
crate::profile_scope!("frame");
|
crate::profile_scope!("frame");
|
||||||
|
|
||||||
let (integration, app, glutin, painter) = {
|
let (integration, app, glutin, painter) = {
|
||||||
let running = self.running.borrow();
|
let running = self.running.as_ref().unwrap();
|
||||||
let running = running.as_ref().unwrap();
|
|
||||||
(
|
(
|
||||||
running.integration.clone(),
|
running.integration.clone(),
|
||||||
running.app.clone(),
|
running.app.clone(),
|
||||||
@@ -1530,7 +1524,7 @@ mod glow_integration {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
let gl = self.running.borrow().as_ref().unwrap().gl.clone();
|
let gl = self.running.as_ref().unwrap().gl.clone();
|
||||||
|
|
||||||
egui_glow::painter::clear(
|
egui_glow::painter::clear(
|
||||||
&gl,
|
&gl,
|
||||||
@@ -1674,7 +1668,7 @@ mod glow_integration {
|
|||||||
|
|
||||||
Ok(match event {
|
Ok(match event {
|
||||||
winit::event::Event::Resumed => {
|
winit::event::Event::Resumed => {
|
||||||
if self.running.borrow().is_none() {
|
if self.running.is_none() {
|
||||||
// first resume event.
|
// first resume event.
|
||||||
// we can actually move this outside of event loop.
|
// we can actually move this outside of event loop.
|
||||||
// and just run the on_resume fn of gl_window
|
// and just run the on_resume fn of gl_window
|
||||||
@@ -1682,7 +1676,6 @@ mod glow_integration {
|
|||||||
} else {
|
} else {
|
||||||
// not the first resume event. create whatever you need.
|
// not the first resume event. create whatever you need.
|
||||||
self.running
|
self.running
|
||||||
.borrow_mut()
|
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.glutin_ctx
|
.glutin_ctx
|
||||||
@@ -1691,7 +1684,6 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
EventResult::RepaintNow(
|
EventResult::RepaintNow(
|
||||||
self.running
|
self.running
|
||||||
.borrow()
|
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.glutin_ctx
|
.glutin_ctx
|
||||||
@@ -1704,7 +1696,6 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
winit::event::Event::Suspended => {
|
winit::event::Event::Suspended => {
|
||||||
self.running
|
self.running
|
||||||
.borrow_mut()
|
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.glutin_ctx
|
.glutin_ctx
|
||||||
@@ -1715,7 +1706,7 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
winit::event::Event::MainEventsCleared => {
|
winit::event::Event::MainEventsCleared => {
|
||||||
if let Some(running) = self.running.borrow().as_ref() {
|
if let Some(running) = self.running.as_ref() {
|
||||||
if let Err(err) = running.glutin_ctx.borrow_mut().on_resume(event_loop) {
|
if let Err(err) = running.glutin_ctx.borrow_mut().on_resume(event_loop) {
|
||||||
log::warn!("on_resume failed {err}");
|
log::warn!("on_resume failed {err}");
|
||||||
}
|
}
|
||||||
@@ -1724,7 +1715,7 @@ mod glow_integration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
winit::event::Event::WindowEvent { event, window_id } => {
|
winit::event::Event::WindowEvent { event, window_id } => {
|
||||||
if let Some(running) = self.running.borrow_mut().as_mut() {
|
if let Some(running) = self.running.as_mut() {
|
||||||
// On Windows, if a window is resized by the user, it should repaint synchronously, inside the
|
// On Windows, if a window is resized by the user, it should repaint synchronously, inside the
|
||||||
// event handler.
|
// event handler.
|
||||||
//
|
//
|
||||||
@@ -1836,7 +1827,7 @@ mod glow_integration {
|
|||||||
winit::event::Event::UserEvent(UserEvent::AccessKitActionRequest(
|
winit::event::Event::UserEvent(UserEvent::AccessKitActionRequest(
|
||||||
accesskit_winit::ActionRequestEvent { request, window_id },
|
accesskit_winit::ActionRequestEvent { request, window_id },
|
||||||
)) => {
|
)) => {
|
||||||
if let Some(running) = self.running.borrow().as_ref() {
|
if let Some(running) = self.running.as_ref() {
|
||||||
crate::profile_scope!("on_accesskit_action_request");
|
crate::profile_scope!("on_accesskit_action_request");
|
||||||
|
|
||||||
let glutin = running.glutin_ctx.borrow();
|
let glutin = running.glutin_ctx.borrow();
|
||||||
|
|||||||
Reference in New Issue
Block a user