From e54455bcad35759c11c629a99840e518e5a68962 Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Mon, 27 May 2024 01:56:09 +0200 Subject: [PATCH] Call `OleInitialize` to fix `DirectWrite` in `TestPlatform` on windows (#12289) Running the tests on windows currently fails for every gpui test using the `TestPlatform` with ```rs called `Result::unwrap()` on an `Err` value: CoInitialize has not been called. (0x800401F0) ``` trying to call `CoCreateInstance`in the `DirectWriteComponent`. The `WindowsPlatform` calls [`OleInitialize`](https://learn.microsoft.com/de-de/windows/win32/api/ole2/nf-ole2-oleinitialize) which internally calls `CoInitializeEx` so I just copied that to the `TestPlatform`. Release Notes: - N/A --- crates/gpui/src/platform/test/platform.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/gpui/src/platform/test/platform.rs b/crates/gpui/src/platform/test/platform.rs index 16898d4636..10c90d8c94 100644 --- a/crates/gpui/src/platform/test/platform.rs +++ b/crates/gpui/src/platform/test/platform.rs @@ -38,6 +38,12 @@ pub(crate) struct TestPrompts { impl TestPlatform { pub fn new(executor: BackgroundExecutor, foreground_executor: ForegroundExecutor) -> Rc { + #[cfg(target_os = "windows")] + unsafe { + windows::Win32::System::Ole::OleInitialize(None) + .expect("unable to initialize Windows OLE"); + } + Rc::new_cyclic(|weak| TestPlatform { background_executor: executor, foreground_executor,