windows: Show error messages when zed failed to lanuch (#32537)
Now, if either `WindowsPlatform` or `BladeRenderer` fails to initialize, a window will pop up to notify the user.  Release Notes: - N/A
This commit is contained in:
parent
7d5a5d0984
commit
a3cc063107
5 changed files with 33 additions and 13 deletions
|
@ -81,9 +81,9 @@ impl WindowsPlatformState {
|
|||
}
|
||||
|
||||
impl WindowsPlatform {
|
||||
pub(crate) fn new() -> Self {
|
||||
pub(crate) fn new() -> Result<Self> {
|
||||
unsafe {
|
||||
OleInitialize(None).expect("unable to initialize Windows OLE");
|
||||
OleInitialize(None).context("unable to initialize Windows OLE")?;
|
||||
}
|
||||
let (main_sender, main_receiver) = flume::unbounded::<Runnable>();
|
||||
let main_thread_id_win32 = unsafe { GetCurrentThreadId() };
|
||||
|
@ -97,19 +97,19 @@ impl WindowsPlatform {
|
|||
let foreground_executor = ForegroundExecutor::new(dispatcher);
|
||||
let bitmap_factory = ManuallyDrop::new(unsafe {
|
||||
CoCreateInstance(&CLSID_WICImagingFactory, None, CLSCTX_INPROC_SERVER)
|
||||
.expect("Error creating bitmap factory.")
|
||||
.context("Error creating bitmap factory.")?
|
||||
});
|
||||
let text_system = Arc::new(
|
||||
DirectWriteTextSystem::new(&bitmap_factory)
|
||||
.expect("Error creating DirectWriteTextSystem"),
|
||||
.context("Error creating DirectWriteTextSystem")?,
|
||||
);
|
||||
let icon = load_icon().unwrap_or_default();
|
||||
let state = RefCell::new(WindowsPlatformState::new());
|
||||
let raw_window_handles = RwLock::new(SmallVec::new());
|
||||
let gpu_context = BladeContext::new().expect("Unable to init GPU context");
|
||||
let windows_version = WindowsVersion::new().expect("Error retrieve windows version");
|
||||
let gpu_context = BladeContext::new().context("Unable to init GPU context")?;
|
||||
let windows_version = WindowsVersion::new().context("Error retrieve windows version")?;
|
||||
|
||||
Self {
|
||||
Ok(Self {
|
||||
state,
|
||||
raw_window_handles,
|
||||
gpu_context,
|
||||
|
@ -122,7 +122,7 @@ impl WindowsPlatform {
|
|||
bitmap_factory,
|
||||
validation_number,
|
||||
main_thread_id_win32,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn redraw_all(&self) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue