diff --git a/imgui/src/context.rs b/imgui/src/context.rs
index 36e785f..f40f6d3 100644
--- a/imgui/src/context.rs
+++ b/imgui/src/context.rs
@@ -664,7 +664,7 @@ impl Context {
backend: Box::new(backend),
};
- *crate::PLATFORM_VIEWPORT_BACKEND.lock().unwrap() = Some(ctx);
+ crate::PLATFORM_VIEWPORT_CONTEXT.with_borrow_mut(|c| *c = Some(ctx));
let pio = self.platform_io_mut();
pio.platform_create_window = Some(docking_utils::platform_create_window);
@@ -703,7 +703,7 @@ impl Context {
backend: Box::new(backend),
};
- *crate::RENDERER_VIEWPORT_BACKEND.lock().unwrap() = Some(ctx);
+ crate::RENDERER_VIEWPORT_CONTEXT.with_borrow_mut(|c| *c = Some(ctx));
let pio = self.platform_io_mut();
pio.renderer_create_window = Some(docking_utils::renderer_create_window);
diff --git a/imgui/src/docking_utils.rs b/imgui/src/docking_utils.rs
index e5d0fd3..f5a4650 100644
--- a/imgui/src/docking_utils.rs
+++ b/imgui/src/docking_utils.rs
@@ -1,17 +1,16 @@
use std::{
- cell::UnsafeCell,
+ cell::RefCell,
ffi::{c_void, CStr},
os::raw::{c_char, c_int},
- sync::Mutex,
};
use crate::{PlatformIo, Viewport};
-pub(crate) static PLATFORM_VIEWPORT_BACKEND: Mutex