diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index ad8275f0ac9de36732e04999cd182e756e14b7a8..670a994d5f18999aa0c987f89a5e3083566a66e5 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -82,6 +82,7 @@ const NSWindowAnimationBehaviorUtilityWindow: NSInteger = 4; #[ctor] unsafe fn build_classes() { + ::util::gpui1_loaded(); WINDOW_CLASS = build_window_class("GPUIWindow", class!(NSWindow)); PANEL_CLASS = build_window_class("GPUIPanel", class!(NSPanel)); VIEW_CLASS = { diff --git a/crates/gpui2/src/platform/mac/window.rs b/crates/gpui2/src/platform/mac/window.rs index babf8aece37dfe5ff6e08aaeb894d1b9b7804a49..a5b0223c9019816d8016f7dd7e3189aed979df7b 100644 --- a/crates/gpui2/src/platform/mac/window.rs +++ b/crates/gpui2/src/platform/mac/window.rs @@ -81,6 +81,8 @@ const NSDragOperationCopy: NSDragOperation = 1; #[ctor] unsafe fn build_classes() { + ::util::gpui2_loaded(); + WINDOW_CLASS = build_window_class("GPUIWindow", class!(NSWindow)); PANEL_CLASS = build_window_class("GPUIPanel", class!(NSPanel)); VIEW_CLASS = { diff --git a/crates/util/src/util.rs b/crates/util/src/util.rs index 629f9500147533a85154995fe2462f5b6d5f5297..77d9e3b4cbad044e226373893efca0446007f283 100644 --- a/crates/util/src/util.rs +++ b/crates/util/src/util.rs @@ -13,6 +13,7 @@ use std::{ ops::{AddAssign, Range, RangeInclusive}, panic::Location, pin::Pin, + sync::atomic::AtomicU32, task::{Context, Poll}, }; @@ -410,6 +411,20 @@ impl RangeExt for RangeInclusive { } } +static GPUI_LOADED: AtomicU32 = AtomicU32::new(0); + +pub fn gpui2_loaded() { + if GPUI_LOADED.fetch_add(2, std::sync::atomic::Ordering::SeqCst) != 0 { + panic!("=========\nYou are loading both GPUI1 and GPUI2 in the same build!\nFix Your Dependencies with cargo tree!\n=========") + } +} + +pub fn gpui1_loaded() { + if GPUI_LOADED.fetch_add(1, std::sync::atomic::Ordering::SeqCst) != 0 { + panic!("=========\nYou are loading both GPUI1 and GPUI2 in the same build!\nFix Your Dependencies with cargo tree!\n=========") + } +} + #[cfg(test)] mod tests { use super::*;