Skip to content

Commit 7abf8af

Browse files
authored
Change Arc<glow::Context> to Rc<glow::Context> (#3598)
This is required for Rust 1.72 (for unknown reasons; see #3595), but also for updating to glow 0.13, where the `glow::Context` is not longer `Sync+Send`
1 parent e823491 commit 7abf8af

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

crates/eframe/src/epi.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct CreationContext<'s> {
6464
///
6565
/// Only available when compiling with the `glow` feature and using [`Renderer::Glow`].
6666
#[cfg(feature = "glow")]
67-
pub gl: Option<std::sync::Arc<glow::Context>>,
67+
pub gl: Option<std::rc::Rc<glow::Context>>,
6868

6969
/// The underlying WGPU render state.
7070
///
@@ -602,7 +602,7 @@ pub struct Frame {
602602

603603
/// A reference to the underlying [`glow`] (OpenGL) context.
604604
#[cfg(feature = "glow")]
605-
pub(crate) gl: Option<std::sync::Arc<glow::Context>>,
605+
pub(crate) gl: Option<std::rc::Rc<glow::Context>>,
606606

607607
/// Can be used to manage GPU resources for custom rendering with WGPU using [`egui::PaintCallback`]s.
608608
#[cfg(feature = "wgpu")]
@@ -674,7 +674,7 @@ impl Frame {
674674
/// To get a [`glow`] context you need to compile with the `glow` feature flag,
675675
/// and run eframe using [`Renderer::Glow`].
676676
#[cfg(feature = "glow")]
677-
pub fn gl(&self) -> Option<&std::sync::Arc<glow::Context>> {
677+
pub fn gl(&self) -> Option<&std::rc::Rc<glow::Context>> {
678678
self.gl.as_ref()
679679
}
680680

crates/eframe/src/native/epi_integration.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl EpiIntegration {
143143
native_options: &crate::NativeOptions,
144144
storage: Option<Box<dyn epi::Storage>>,
145145
is_desktop: bool,
146-
#[cfg(feature = "glow")] gl: Option<std::sync::Arc<glow::Context>>,
146+
#[cfg(feature = "glow")] gl: Option<std::rc::Rc<glow::Context>>,
147147
#[cfg(feature = "wgpu")] wgpu_render_state: Option<egui_wgpu::RenderState>,
148148
) -> Self {
149149
let egui_ctx = egui::Context::default();

crates/eframe/src/native/glow_integration.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl GlowWinitApp {
163163

164164
let gl = unsafe {
165165
crate::profile_scope!("glow::Context::from_loader_function");
166-
Arc::new(glow::Context::from_loader_function(|s| {
166+
Rc::new(glow::Context::from_loader_function(|s| {
167167
let s = std::ffi::CString::new(s)
168168
.expect("failed to construct C string from string for gl proc address");
169169

crates/eframe/src/web/web_painter_glow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(crate) struct WebPainterGlow {
1515
}
1616

1717
impl WebPainterGlow {
18-
pub fn gl(&self) -> &std::sync::Arc<glow::Context> {
18+
pub fn gl(&self) -> &std::rc::Rc<glow::Context> {
1919
self.painter.gl()
2020
}
2121

@@ -24,7 +24,7 @@ impl WebPainterGlow {
2424

2525
let (gl, shader_prefix) =
2626
init_glow_context_from_canvas(&canvas, options.webgl_context_option)?;
27-
let gl = std::sync::Arc::new(gl);
27+
let gl = std::rc::Rc::new(gl);
2828

2929
let painter = egui_glow::Painter::new(gl, shader_prefix, None)
3030
.map_err(|err| format!("Error starting glow painter: {err}"))?;

crates/egui_glow/examples/pure_glow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn main() {
152152

153153
let event_loop = winit::event_loop::EventLoopBuilder::<UserEvent>::with_user_event().build();
154154
let (gl_window, gl) = create_display(&event_loop);
155-
let gl = std::sync::Arc::new(gl);
155+
let gl = std::rc::Rc::new(gl);
156156

157157
let mut egui_glow = egui_glow::EguiGlow::new(&event_loop, gl.clone(), None, None);
158158

crates/egui_glow/src/painter.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(clippy::collapsible_else_if)]
22
#![allow(unsafe_code)]
33

4-
use std::{collections::HashMap, sync::Arc};
4+
use std::{collections::HashMap, rc::Rc};
55

66
use egui::{
77
emath::Rect,
@@ -60,7 +60,7 @@ impl From<String> for PainterError {
6060
/// This struct must be destroyed with [`Painter::destroy`] before dropping, to ensure OpenGL
6161
/// objects have been properly deleted and are not leaked.
6262
pub struct Painter {
63-
gl: Arc<glow::Context>,
63+
gl: Rc<glow::Context>,
6464

6565
max_texture_side: usize,
6666

@@ -118,7 +118,7 @@ impl Painter {
118118
/// * failed to create postprocess on webgl with `sRGB` support
119119
/// * failed to create buffer
120120
pub fn new(
121-
gl: Arc<glow::Context>,
121+
gl: Rc<glow::Context>,
122122
shader_prefix: &str,
123123
shader_version: Option<ShaderVersion>,
124124
) -> Result<Painter, PainterError> {
@@ -248,7 +248,7 @@ impl Painter {
248248
}
249249

250250
/// Access the shared glow context.
251-
pub fn gl(&self) -> &Arc<glow::Context> {
251+
pub fn gl(&self) -> &Rc<glow::Context> {
252252
&self.gl
253253
}
254254

crates/egui_glow/src/winit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl EguiGlow {
2424
/// For automatic shader version detection set `shader_version` to `None`.
2525
pub fn new<E>(
2626
event_loop: &winit::event_loop::EventLoopWindowTarget<E>,
27-
gl: std::sync::Arc<glow::Context>,
27+
gl: std::rc::Rc<glow::Context>,
2828
shader_version: Option<ShaderVersion>,
2929
native_pixels_per_point: Option<f32>,
3030
) -> Self {

0 commit comments

Comments
 (0)